From e972fc8b9bcf91825fa7c9fc68d89d49b7c25aef Mon Sep 17 00:00:00 2001 From: Oleh Posyniak <oposyniak@magento.com> Date: Mon, 29 Aug 2016 15:26:25 +0300 Subject: [PATCH] MAGETWO-56343: Setup tool check PHP extensions does not check for all needed extensions --- composer.json | 1 + composer.lock | 7 +++-- .../Magento/Setup/Model/PhpReadinessCheck.php | 30 ++++++++++++++++++- .../Test/Unit/Model/PhpReadinessCheckTest.php | 23 ++++++++++++-- 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 8053b76a01a..a0813c84620 100644 --- a/composer.json +++ b/composer.json @@ -64,6 +64,7 @@ "ext-mbstring": "*", "ext-openssl": "*", "ext-zip": "*", + "ext-pdo_mysql": "*", "sjparkinson/static-review": "~4.1", "ramsey/uuid": "3.4" }, diff --git a/composer.lock b/composer.lock index 6fd73ef405c..4d1f23dad9b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "ad3de2234f78fd4b353ae6a1b22401fc", - "content-hash": "25dcf96ed1d8b12a25111e8b3af61317", + "hash": "c8f9e4332a46ace884514d9843021898", + "content-hash": "fa9bd2b88f3c2e1bf562c439cecca917", "packages": [ { "name": "braintree/braintree_php", @@ -4597,7 +4597,8 @@ "ext-xsl": "*", "ext-mbstring": "*", "ext-openssl": "*", - "ext-zip": "*" + "ext-zip": "*", + "ext-pdo_mysql": "*" }, "platform-dev": [] } diff --git a/setup/src/Magento/Setup/Model/PhpReadinessCheck.php b/setup/src/Magento/Setup/Model/PhpReadinessCheck.php index 06e8b34471d..bcf942687a4 100644 --- a/setup/src/Magento/Setup/Model/PhpReadinessCheck.php +++ b/setup/src/Magento/Setup/Model/PhpReadinessCheck.php @@ -102,7 +102,8 @@ class PhpReadinessCheck $settings = array_merge( $this->checkXDebugNestedLevel(), - $this->checkPopulateRawPostSetting() + $this->checkPopulateRawPostSetting(), + $this->checkFunctionsExistence() ); foreach ($settings as $setting) { @@ -316,6 +317,33 @@ class PhpReadinessCheck return $data; } + /** + * Check whether all special functions exists + * + * @return array + */ + private function checkFunctionsExistence() + { + $data = []; + $requiredFunctions = [ + [ + 'name' => 'imagecreatefromjpeg', + 'message' => 'You must have installed GD library wuth --with-jpeg-dir=DIR option.', + 'helpUrl' => 'http://php.net/manual/en/image.installation.php', + ], + ]; + + foreach ($requiredFunctions as $function) { + $data['missed_function_' . $function['name']] = [ + 'message' => $function['message'], + 'helpUrl' => $function['helpUrl'], + 'error' => !function_exists($function['name']), + ]; + } + + return $data; + } + /** * Normalize PHP Version * diff --git a/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php b/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php index c24e1792331..785674dbae3 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/PhpReadinessCheckTest.php @@ -222,7 +222,12 @@ class PhpReadinessCheckTest extends \PHPUnit_Framework_TestCase 'message' => $xdebugMessage, 'error' => false, ], - ] + 'missed_function_imagecreatefromjpeg' => [ + 'message' => 'You must have installed GD library wuth --with-jpeg-dir=DIR option.', + 'helpUrl' => 'http://php.net/manual/en/image.installation.php', + 'error' => false, + ], + ], ]; if (!$this->isPhp7OrHhvm()) { $this->setUpNoPrettyVersionParser(); @@ -261,8 +266,13 @@ class PhpReadinessCheckTest extends \PHPUnit_Framework_TestCase 'xdebug_max_nesting_level' => [ 'message' => $xdebugMessage, 'error' => true, - ] - ] + ], + 'missed_function_imagecreatefromjpeg' => [ + 'message' => 'You must have installed GD library wuth --with-jpeg-dir=DIR option.', + 'helpUrl' => 'http://php.net/manual/en/image.installation.php', + 'error' => false, + ], + ], ]; if (!$this->isPhp7OrHhvm()) { $this->setUpNoPrettyVersionParser(); @@ -301,6 +311,13 @@ class PhpReadinessCheckTest extends \PHPUnit_Framework_TestCase ] ]; } + + $expected['data']['missed_function_imagecreatefromjpeg'] = [ + 'message' => 'You must have installed GD library wuth --with-jpeg-dir=DIR option.', + 'helpUrl' => 'http://php.net/manual/en/image.installation.php', + 'error' => false, + ]; + $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpSettings()); } -- GitLab