diff --git a/app/code/Magento/PageCache/Controller/Block/Render.php b/app/code/Magento/PageCache/Controller/Block/Render.php index 2758db3f574214ca247997de092f4cc580c990e3..8afaeb27e5c3a552d83e8a72d1a940ddab4434ba 100644 --- a/app/code/Magento/PageCache/Controller/Block/Render.php +++ b/app/code/Magento/PageCache/Controller/Block/Render.php @@ -19,7 +19,8 @@ class Render extends \Magento\PageCache\Controller\Block $this->_forward('noroute'); return; } - + // disable profiling during private content handling AJAX call + \Magento\Framework\Profiler::reset(); $blocks = $this->_getBlocks(); $data = []; foreach ($blocks as $blockName => $blockInstance) { diff --git a/app/etc/vendor_path.php b/app/etc/vendor_path.php index bd9482bb36ae0879f2f38c9747b28b05f99413e0..b6af03ef32fa48938f0a80ce7194f177a56e1177 100755 --- a/app/etc/vendor_path.php +++ b/app/etc/vendor_path.php @@ -1,10 +1,5 @@ <?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - /** * Path to Composer vendor directory */ -return 'vendor'; +return './vendor'; diff --git a/composer.json b/composer.json index f22f996c07214bdff779c678a7c4615c1f0f02a8..e29f9de8be6ff85c6eeebf84e5da449dedeba559 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,8 @@ "magento/zendframework1": "1.12.10", "composer/composer": "1.0.0-alpha8", "monolog/monolog": "1.11.0", - "tubalmartin/cssmin": "2.4.8-p4" + "tubalmartin/cssmin": "2.4.8-p4", + "magento/magento-composer-installer": "*" }, "require-dev": { "phpunit/phpunit": "4.1.0", @@ -194,7 +195,8 @@ }, "autoload": { "psr-4": { - "Magento\\Framework\\": "lib/internal/Magento/Framework/" + "Magento\\Framework\\": "lib/internal/Magento/Framework/", + "Magento\\Setup\\": "setup/src/Magento/Setup/" } }, "autoload-dev": { @@ -204,8 +206,7 @@ "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/", "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/", "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/", - "Magento\\ToolkitFramework\\": "dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/", - "Magento\\Setup\\": "setup/src/Magento/Setup/" + "Magento\\ToolkitFramework\\": "dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/" } } } diff --git a/composer.lock b/composer.lock index 02b43c39d185181e4bb80017a35c3dcb4b364d35..5337e32b2c094312a9be6fb56bafbc7632a931d5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "498056a32c33c43d23e5d2ee37362a2d", + "hash": "933a1cf749db0c7e6d16e357c12cdaa8", "packages": [ { "name": "composer/composer", @@ -131,6 +131,82 @@ ], "time": "2012-01-03 00:33:17" }, + { + "name": "magento/magento-composer-installer", + "version": "0.1.4", + "source": { + "type": "git", + "url": "https://github.com/magento/magento-composer-installer.git", + "reference": "7f03451f71e55d52c2bb07325d56a4e6df322f30" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/magento/magento-composer-installer/zipball/7f03451f71e55d52c2bb07325d56a4e6df322f30", + "reference": "7f03451f71e55d52c2bb07325d56a4e6df322f30", + "shasum": "" + }, + "require": { + "composer-plugin-api": "1.0.0" + }, + "require-dev": { + "composer/composer": "*@dev", + "firegento/phpcs": "dev-patch-1", + "mikey179/vfsstream": "*", + "phpunit/phpunit": "*", + "phpunit/phpunit-mock-objects": "dev-master", + "squizlabs/php_codesniffer": "1.4.7", + "symfony/process": "*" + }, + "type": "composer-plugin", + "extra": { + "composer-command-registry": [ + "MagentoHackathon\\Composer\\Magento\\Command\\DeployCommand" + ], + "class": "MagentoHackathon\\Composer\\Magento\\Plugin" + }, + "autoload": { + "psr-0": { + "MagentoHackathon\\Composer\\Magento": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "OSL-3.0" + ], + "authors": [ + { + "name": "Vinai Kopp", + "email": "vinai@netzarbeiter.com" + }, + { + "name": "Daniel Fahlke aka Flyingmana", + "email": "flyingmana@googlemail.com" + }, + { + "name": "Jörg Weller", + "email": "weller@flagbit.de" + }, + { + "name": "Karl Spies", + "email": "karl.spies@gmx.net" + }, + { + "name": "Tobias Vogt", + "email": "tobi@webguys.de" + }, + { + "name": "David Fuhr", + "email": "fuhr@flagbit.de" + } + ], + "description": "Composer installer for Magento modules", + "homepage": "https://github.com/magento/magento-composer-installer", + "keywords": [ + "composer-installer", + "magento" + ], + "time": "2015-03-05 21:40:30" + }, { "name": "magento/zendframework1", "version": "1.12.10", diff --git a/dev/tools/Magento/Tools/View/deploy.php b/dev/tools/Magento/Tools/View/deploy.php index a68a977243964261d716a16e629bb126f5f8aadb..765ac7e4acaddb0e106bfa98f56e8eb96f11ddf3 100644 --- a/dev/tools/Magento/Tools/View/deploy.php +++ b/dev/tools/Magento/Tools/View/deploy.php @@ -16,10 +16,7 @@ $options = getopt('', ['langs::', 'dry-run', 'verbose::', 'help']); define('USAGE', "USAGE:\n\tphp -f {$baseName} -- [--langs=en_US,de_DE,...] [--verbose=0|1] [--dry-run] [--help]\n"); require __DIR__ . '/../../../../../app/bootstrap.php'; -AutoloaderRegistry::getAutoloader()->addPsr4( - 'Magento\\', - [BP . '/dev/tests/static/framework/Magento/', realpath(__DIR__ . '/../../../Magento/')] -); +AutoloaderRegistry::getAutoloader()->addPsr4('Magento\\', [BP . '/tools/Magento/']); // parse all options if (isset($options['help'])) { @@ -42,26 +39,31 @@ if (isset($options['verbose'])) { $verbosity = 0 === (int)$options['verbose'] ? \Magento\Tools\View\Deployer\Log::SILENT : \Magento\Tools\View\Deployer\Log::ERROR | \Magento\Tools\View\Deployer\Log::DEBUG; } +$logger = new \Magento\Tools\View\Deployer\Log($verbosity); -// run the deployment logic -$filesUtil = new \Magento\Framework\App\Utility\Files(BP); -$omFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, []); -$objectManager = $omFactory->create( - [\Magento\Framework\App\State::PARAM_MODE => \Magento\Framework\App\State::MODE_DEFAULT] -); +try { + // run the deployment logic + $filesUtil = new \Magento\Framework\Test\Utility\Files(BP); + $omFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, []); + $objectManager = $omFactory->create( + [\Magento\Framework\App\State::PARAM_MODE => \Magento\Framework\App\State::MODE_DEFAULT] + ); -/** @var \Magento\Framework\App\DeploymentConfig $deploymentConfig */ -$deploymentConfig = $objectManager->get('Magento\Framework\App\DeploymentConfig'); -$isAppInstalled = $deploymentConfig->isAvailable(); -if (!$isAppInstalled) { - throw new \Exception('Please install the Magento application before running this process.'); -} + /** @var \Magento\Framework\App\DeploymentConfig $deploymentConfig */ + $deploymentConfig = $objectManager->get('Magento\Framework\App\DeploymentConfig'); + $isAppInstalled = $deploymentConfig->isAvailable(); + if (!$isAppInstalled) { + throw new \Exception('You need to install the Magento application before running this utility.'); + } -$logger = new \Magento\Tools\View\Deployer\Log($verbosity); -/** @var \Magento\Tools\View\Deployer $deployer */ -$deployer = $objectManager->create( - 'Magento\Tools\View\Deployer', - ['filesUtil' => $filesUtil, 'logger' => $logger, 'isDryRun' => $isDryRun] -); -$deployer->deploy($omFactory, $langs); -exit(0); + /** @var \Magento\Tools\View\Deployer $deployer */ + $deployer = $objectManager->create( + 'Magento\Tools\View\Deployer', + ['filesUtil' => $filesUtil, 'logger' => $logger, 'isDryRun' => $isDryRun] + ); + $deployer->deploy($omFactory, $langs); +} catch (\Exception $e) { + $logger->logError($e->getMessage()); + $logger->logDebug($e->getTraceAsString()); + exit(1); +} diff --git a/lib/internal/Magento/Framework/App/StaticResource.php b/lib/internal/Magento/Framework/App/StaticResource.php index 45fe01dac839dc28c47816a70c27a085eb53fd86..a4df94fc2eafdf67458801a82ac574f721a7f3c9 100644 --- a/lib/internal/Magento/Framework/App/StaticResource.php +++ b/lib/internal/Magento/Framework/App/StaticResource.php @@ -99,6 +99,8 @@ class StaticResource implements \Magento\Framework\AppInterface */ public function launch() { + // disabling profiling when retrieving static resource + \Magento\Framework\Profiler::reset(); $appMode = $this->state->getMode(); if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION) { $this->response->setHttpResponseCode(404); diff --git a/lib/internal/Magento/Framework/Module/ModuleList/DeploymentConfigFactory.php b/lib/internal/Magento/Framework/Module/ModuleList/DeploymentConfigFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..c7b92525fa6a2f25c77f2343aac8219bcfc14cf3 --- /dev/null +++ b/lib/internal/Magento/Framework/Module/ModuleList/DeploymentConfigFactory.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Module\ModuleList; + +/** + * Factory for Deployment configuration segment for modules + */ +class DeploymentConfigFactory +{ + /** + * Factory method for Deployment Config object + * + * @param array $data + * @return DeploymentConfig + */ + public function create(array $data) + { + return new DeploymentConfig($data); + } +} diff --git a/lib/internal/Magento/Framework/Module/Status.php b/lib/internal/Magento/Framework/Module/Status.php index 3fca3995780ab3a1fc4bb27e26cd306a2bdf478e..d71a48fc3c6680fc69a414f1c8512ae592597f5c 100644 --- a/lib/internal/Magento/Framework/Module/Status.php +++ b/lib/internal/Magento/Framework/Module/Status.php @@ -7,10 +7,13 @@ namespace Magento\Framework\Module; use Magento\Framework\App\DeploymentConfig\Writer; +use Magento\Framework\Module\ModuleList\DeploymentConfigFactory; use Magento\Framework\App\State\Cleanup; /** * A service for controlling module status + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Status { @@ -56,6 +59,13 @@ class Status */ private $conflictChecker; + /** + * Factory to create module deployment config object + * + * @var DeploymentConfigFactory + */ + private $deploymentConfigFactory; + /** * Constructor * @@ -65,6 +75,7 @@ class Status * @param Cleanup $cleanup * @param ConflictChecker $conflictChecker * @param DependencyChecker $dependencyChecker + * @param DeploymentConfigFactory $deploymentConfigFactory */ public function __construct( ModuleList\Loader $loader, @@ -72,7 +83,8 @@ class Status Writer $writer, Cleanup $cleanup, ConflictChecker $conflictChecker, - DependencyChecker $dependencyChecker + DependencyChecker $dependencyChecker, + DeploymentConfigFactory $deploymentConfigFactory ) { $this->loader = $loader; $this->list = $list; @@ -80,6 +92,7 @@ class Status $this->cleanup = $cleanup; $this->conflictChecker = $conflictChecker; $this->dependencyChecker = $dependencyChecker; + $this->deploymentConfigFactory = $deploymentConfigFactory; } /** @@ -159,7 +172,7 @@ class Status $result[$name] = $currentStatus; } } - $segment = new ModuleList\DeploymentConfig($result); + $segment = $this->deploymentConfigFactory->create($result); $this->writer->update($segment); $this->cleanup->clearCaches(); $this->cleanup->clearCodeGeneratedFiles(); diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleList/DeploymentConfigFactoryTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleList/DeploymentConfigFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..fc07edc800666e6451e67cdf88893055dcc1e9e7 --- /dev/null +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleList/DeploymentConfigFactoryTest.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Module\Test\Unit\ModuleList; + +use Magento\Framework\Module\ModuleList\DeploymentConfigFactory; + +class DeploymentConfigFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DeploymentConfigFactory + */ + protected $object; + + public function testCreate() + { + $this->object = new DeploymentConfigFactory(); + $this->assertInstanceOf( + 'Magento\Framework\Module\ModuleList\DeploymentConfig', + $this->object->create(['Module_One' => 0, 'Module_Two' =>1]) + ); + } +} diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php index 36ae599d5f570cf9caaa35b9e84edb5c06cd509d..f469783e91b5811c417b3d06b6c22754e3647a7e 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php @@ -40,6 +40,11 @@ class StatusTest extends \PHPUnit_Framework_TestCase */ private $dependencyChecker; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $deploymentConfigFactory; + /** * @var Status */ @@ -53,13 +58,21 @@ class StatusTest extends \PHPUnit_Framework_TestCase $this->cleanup = $this->getMock('Magento\Framework\App\State\Cleanup', [], [], '', false); $this->conflictChecker = $this->getMock('Magento\Framework\Module\ConflictChecker', [], [], '', false); $this->dependencyChecker = $this->getMock('Magento\Framework\Module\DependencyChecker', [], [], '', false); + $this->deploymentConfigFactory = $this->getMock( + 'Magento\Framework\Module\ModuleList\DeploymentConfigFactory', + [], + [], + '', + false + ); $this->object = new Status( $this->loader, $this->moduleList, $this->writer, $this->cleanup, $this->conflictChecker, - $this->dependencyChecker + $this->dependencyChecker, + $this->deploymentConfigFactory ); } @@ -167,10 +180,11 @@ class StatusTest extends \PHPUnit_Framework_TestCase $this->moduleList->expects($this->at(0))->method('has')->with('Module_Foo')->willReturn(false); $this->moduleList->expects($this->at(1))->method('has')->with('Module_Bar')->willReturn(false); $this->moduleList->expects($this->at(2))->method('has')->with('Module_Baz')->willReturn(false); - $constraint = new \PHPUnit_Framework_Constraint_IsInstanceOf( - 'Magento\Framework\Module\ModuleList\DeploymentConfig' - ); - $this->writer->expects($this->once())->method('update')->with($constraint); + $deploymentConfig = $this->getMock('Magento\Framework\Module\ModuleList\DeploymentConfig', [], [], '', false); + $expectedModules = ['Module_Foo' => 1, 'Module_Bar' => 1, 'Module_Baz' => 0]; + $this->deploymentConfigFactory->expects($this->once())->method('create')->with($expectedModules) + ->willReturn($deploymentConfig); + $this->writer->expects($this->once())->method('update')->with($deploymentConfig); $this->cleanup->expects($this->once())->method('clearCaches'); $this->cleanup->expects($this->once())->method('clearCodeGeneratedFiles'); $this->object->setIsEnabled(true, ['Module_Foo', 'Module_Bar']); diff --git a/setup/pub/magento/setup/add-database.js b/setup/pub/magento/setup/add-database.js index b6dde9b8caf56179eb66b6c1cbab057e13bb5e60..af4e87b7680d3443883e569c3518ba96b1d0d3f9 100644 --- a/setup/pub/magento/setup/add-database.js +++ b/setup/pub/magento/setup/add-database.js @@ -22,9 +22,12 @@ angular.module('add-database', ['ngStorage']) $http.post('index.php/database-check', $scope.db) .success(function (data) { $scope.testConnection.result = data; - if (!(($scope.testConnection.result !== undefined) && (!$scope.testConnection.result.success))) { + if ($scope.testConnection.result.success) { $scope.nextState(); } + }) + .error(function (data) { + $scope.testConnection.failed = data; }); }; diff --git a/setup/pub/magento/setup/readiness-check.js b/setup/pub/magento/setup/readiness-check.js index 2c46b35064292264e2a117a23a22d0e4bda4b4f5..d7c0eb243e2fccce768b7eec41e4b5b414ca7584 100644 --- a/setup/pub/magento/setup/readiness-check.js +++ b/setup/pub/magento/setup/readiness-check.js @@ -32,6 +32,11 @@ angular.module('readiness-check', []) processed: false, expanded: false }; + $scope.rawpost = { + visible: false, + processed: false, + expanded: false + }; $scope.extensions = { visible: false, processed: false, @@ -57,6 +62,19 @@ angular.module('readiness-check', []) $scope.stopProgress(); } }, + 'php-rawpost': { + url:'index.php/environment/php-rawpost', + show: function() { + $scope.startProgress(); + $scope.rawpost.visible = true; + }, + process: function(data) { + $scope.rawpost.processed = true; + angular.extend($scope.rawpost, data); + $scope.updateOnProcessed($scope.rawpost.responseType); + $scope.stopProgress(); + } + }, 'php-extensions': { url:'index.php/environment/php-extensions', show: function() { diff --git a/setup/src/Magento/Setup/Controller/ConsoleController.php b/setup/src/Magento/Setup/Controller/ConsoleController.php index 1e59a5e9db82533a6f3c37c0dc8e38003ef265da..58bf6d31f91660d2b24cb931f7dbd809adf7ca2c 100644 --- a/setup/src/Magento/Setup/Controller/ConsoleController.php +++ b/setup/src/Magento/Setup/Controller/ConsoleController.php @@ -317,6 +317,8 @@ class ConsoleController extends AbstractActionController $this->installer = $installerFactory->create($consoleLogger); $this->maintenanceMode = $maintenanceMode; $this->objectManagerProvider = $objectManagerProvider; + // By default we use our customized error handler, but for CLI we want to display all errors + restore_error_handler(); } /** @@ -405,6 +407,7 @@ class ConsoleController extends AbstractActionController */ public function updateAction() { + $this->installer->updateModulesSequence(); $this->installer->installSchema(); $this->installer->installDataFixtures(); } diff --git a/setup/src/Magento/Setup/Controller/Environment.php b/setup/src/Magento/Setup/Controller/Environment.php index 07dc89aff7db5eec32e2e8ae73f7bffc7f089f2c..8b93843046fb95d46f2abc1558a43f586fac0e47 100644 --- a/setup/src/Magento/Setup/Controller/Environment.php +++ b/setup/src/Magento/Setup/Controller/Environment.php @@ -87,6 +87,29 @@ class Environment extends AbstractActionController return new JsonModel($data); } + /** + * Checks if PHP version >= 5.6.0 and always_populate_raw_post_data is set + * + * @return JsonModel + */ + public function phpRawpostAction() + { + $iniSetting = ini_get('always_populate_raw_post_data'); + $responseType = ResponseTypeInterface::RESPONSE_TYPE_SUCCESS; + if (version_compare(PHP_VERSION, '5.6.0') >= 0 && (int)$iniSetting > -1) { + $responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR; + } + $data = [ + 'responseType' => $responseType, + 'data' => [ + 'version' => PHP_VERSION, + 'ini' => ini_get('always_populate_raw_post_data') + ] + ]; + + return new JsonModel($data); + } + /** * Verifies php verifications * diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php index aaac7d81ac2e8f9fd85973faaa53170d317df449..0b2772d9f45c4684f7baeab5b7dd3f1c063d35a9 100644 --- a/setup/src/Magento/Setup/Model/Installer.php +++ b/setup/src/Magento/Setup/Model/Installer.php @@ -13,12 +13,14 @@ use Magento\Framework\App\DeploymentConfig\InstallConfig; use Magento\Framework\App\DeploymentConfig\ResourceConfig; use Magento\Framework\App\DeploymentConfig\SessionConfig; use Magento\Framework\App\DeploymentConfig\Writer; +use Magento\Framework\App\DeploymentConfig\Reader; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\MaintenanceMode; use Magento\Framework\Filesystem; use Magento\Framework\Filesystem\FilesystemException; use Magento\Framework\Math\Random; use Magento\Framework\Module\ModuleList\DeploymentConfig; +use Magento\Framework\Module\ModuleList\DeploymentConfigFactory; use Magento\Framework\Module\ModuleList\Loader as ModuleLoader; use Magento\Framework\Module\ModuleListInterface; use Magento\Framework\Shell; @@ -102,6 +104,13 @@ class Installer */ private $deploymentConfigWriter; + /** + * Deployment configuration reader + * + * @var Writer + */ + private $deploymentConfigReader; + /** * Module list * @@ -109,6 +118,13 @@ class Installer */ private $moduleList; + /** + * Factory for module deployment config + * + * @var DeploymentConfigFactory + */ + private $deploymentConfigFactory; + /** * Module list loader * @@ -211,7 +227,9 @@ class Installer * * @param FilePermissions $filePermissions * @param Writer $deploymentConfigWriter + * @param Reader $deploymentConfigReader * @param \Magento\Framework\App\DeploymentConfig $deploymentConfig + * @param DeploymentConfigFactory $deploymentConfigFactory * @param ModuleListInterface $moduleList * @param ModuleLoader $moduleLoader * @param DirectoryList $directoryList @@ -230,7 +248,9 @@ class Installer public function __construct( FilePermissions $filePermissions, Writer $deploymentConfigWriter, + Reader $deploymentConfigReader, \Magento\Framework\App\DeploymentConfig $deploymentConfig, + DeploymentConfigFactory $deploymentConfigFactory, ModuleListInterface $moduleList, ModuleLoader $moduleLoader, DirectoryList $directoryList, @@ -246,6 +266,8 @@ class Installer ) { $this->filePermissions = $filePermissions; $this->deploymentConfigWriter = $deploymentConfigWriter; + $this->deploymentConfigReader = $deploymentConfigReader; + $this->deploymentConfigFactory = $deploymentConfigFactory; $this->moduleList = $moduleList; $this->moduleLoader = $moduleLoader; $this->directoryList = $directoryList; @@ -336,7 +358,7 @@ class Installer $key = array_search($module, $toEnable); $result[$module] = false !== $key; } - return new DeploymentConfig($result); + return $this->deploymentConfigFactory->create($result); } /** @@ -786,6 +808,33 @@ class Installer $adminAccount->save(); } + /** + * Updates modules in deployment configuration + * + * @return void + */ + public function updateModulesSequence() + { + $this->assertDeploymentConfigExists(); + $this->log->log('File system cleanup:'); + $this->deleteDirContents(DirectoryList::GENERATION); + $this->deleteDirContents(DirectoryList::CACHE); + $this->log->log('Updating modules:'); + $allModules = array_keys($this->moduleLoader->load()); + $deploymentConfig = $this->deploymentConfigReader->load(); + $currentModules = isset($deploymentConfig['modules']) ? $deploymentConfig['modules'] : [] ; + $result = []; + foreach ($allModules as $module) { + if (isset($currentModules[$module]) && !$currentModules[$module]) { + $result[$module] = 0; + } else { + $result[$module] = 1; + } + } + $segment = $this->deploymentConfigFactory->create($result); + $this->deploymentConfigWriter->update($segment); + } + /** * Uninstall Magento application * diff --git a/setup/src/Magento/Setup/Model/InstallerFactory.php b/setup/src/Magento/Setup/Model/InstallerFactory.php index 826c37a97841d6d417b959e1cab2298e0f933d84..6ed7fbb8d3019080ed16fa3404780f1fbc14947b 100644 --- a/setup/src/Magento/Setup/Model/InstallerFactory.php +++ b/setup/src/Magento/Setup/Model/InstallerFactory.php @@ -8,6 +8,7 @@ namespace Magento\Setup\Model; use Zend\ServiceManager\ServiceLocatorInterface; use Magento\Setup\Module\ResourceFactory; +use Magento\Framework\App\ErrorHandler; class InstallerFactory { @@ -33,6 +34,9 @@ class InstallerFactory { $this->serviceLocator = $serviceLocator; $this->resourceFactory = $resourceFactory; + // For Setup Wizard we are using our customized error handler + $handler = new ErrorHandler(); + set_error_handler([$handler, 'handler']); } /** @@ -46,7 +50,9 @@ class InstallerFactory return new Installer( $this->serviceLocator->get('Magento\Setup\Model\FilePermissions'), $this->serviceLocator->get('Magento\Framework\App\DeploymentConfig\Writer'), + $this->serviceLocator->get('Magento\Framework\App\DeploymentConfig\Reader'), $this->serviceLocator->get('Magento\Framework\App\DeploymentConfig'), + $this->serviceLocator->get('Magento\Framework\Module\ModuleList\DeploymentConfigFactory'), $this->serviceLocator->get('Magento\Framework\Module\ModuleList'), $this->serviceLocator->get('Magento\Framework\Module\ModuleList\Loader'), $this->serviceLocator->get('Magento\Framework\App\Filesystem\DirectoryList'), diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php index 098be45fdb17f73af2168e26981f8a0f825905b0..06d50d55d388e6a390971e730228fcf82aa97da1 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php @@ -165,8 +165,9 @@ class ConsoleControllerTest extends \PHPUnit_Framework_TestCase public function testUpdateAction() { - $this->installer->expects($this->once())->method('installSchema'); - $this->installer->expects($this->once())->method('installDataFixtures'); + $this->installer->expects($this->at(0))->method('updateModulesSequence'); + $this->installer->expects($this->at(1))->method('installSchema'); + $this->installer->expects($this->at(2))->method('installDataFixtures'); $this->controller->updateAction(); } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php index 19746c6b5d179a20d4de2eee695158caa001134d..bde3f74878cf367016ef7884bb1356f491079e37 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php @@ -21,6 +21,10 @@ class InstallerFactoryTest extends \PHPUnit_Framework_TestCase 'Magento\Framework\App\DeploymentConfig\Writer', $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false), ], + [ + 'Magento\Framework\App\DeploymentConfig\Reader', + $this->getMock('Magento\Framework\App\DeploymentConfig\Reader', [], [], '', false), + ], [ 'Magento\Framework\App\DeploymentConfig', $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false), @@ -29,6 +33,10 @@ class InstallerFactoryTest extends \PHPUnit_Framework_TestCase 'Magento\Setup\Module\Setup', $this->getMock('Magento\Setup\Module\Setup', [], [], '', false), ], + [ + 'Magento\Framework\Module\ModuleList\DeploymentConfigFactory', + $this->getMock('Magento\Framework\Module\ModuleList\DeploymentConfigFactory', [], [], '', false), + ], [ 'Magento\Framework\Module\ModuleList', $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false), diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php index 1343dc2151c7b4afd1b7af5d9113b4673d7d0c42..b780bb25a335ac92aa8c0808d7acb6c5e0d265ab 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php @@ -35,6 +35,11 @@ class InstallerTest extends \PHPUnit_Framework_TestCase */ private $configWriter; + /** + * @var \Magento\Framework\App\DeploymentConfig\Reader|\PHPUnit_Framework_MockObject_MockObject + */ + private $configReader; + /** * @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject */ @@ -50,6 +55,16 @@ class InstallerTest extends \PHPUnit_Framework_TestCase */ private $moduleLoader; + /** + * @var \Magento\Framework\Module\ModuleList\DeploymentConfigFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $deploymentConfigFactory; + + /** + * @var \Magento\Framework\Module\ModuleList\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject + */ + private $deploymentConfig; + /** * @var \Magento\Framework\App\Filesystem\DirectoryList|\PHPUnit_Framework_MockObject_MockObject */ @@ -121,6 +136,7 @@ class InstallerTest extends \PHPUnit_Framework_TestCase { $this->filePermissions = $this->getMock('Magento\Setup\Model\FilePermissions', [], [], '', false); $this->configWriter = $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false); + $this->configReader = $this->getMock('Magento\Framework\App\DeploymentConfig\Reader', [], [], '', false); $this->config = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); $this->moduleList = $this->getMockForAbstractClass('Magento\Framework\Module\ModuleListInterface'); @@ -131,11 +147,20 @@ class InstallerTest extends \PHPUnit_Framework_TestCase ['Foo_One', 'Bar_Two'] ); $this->moduleLoader = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false); - $allModules = [ - 'Foo_One' => [], - 'Bar_Two' => [], - ]; - $this->moduleLoader->expects($this->any())->method('load')->willReturn($allModules); + $this->deploymentConfigFactory = $this->getMock( + 'Magento\Framework\Module\ModuleList\DeploymentConfigFactory', + [], + [], + '', + false + ); + $this->deploymentConfig = $this->getMock( + 'Magento\Framework\Module\ModuleList\DeploymentConfig', + [], + [], + '', + false + ); $this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); $this->adminFactory = $this->getMock('Magento\Setup\Model\AdminAccountFactory', [], [], '', false); $this->logger = $this->getMockForAbstractClass('Magento\Setup\Model\LoggerInterface'); @@ -166,10 +191,13 @@ class InstallerTest extends \PHPUnit_Framework_TestCase $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); $objectManagerProvider->expects($this->any())->method('get')->willReturn($this->objectManager); } + return new Installer( $this->filePermissions, $this->configWriter, + $this->configReader, $this->config, + $this->deploymentConfigFactory, $this->moduleList, $this->moduleLoader, $this->directoryList, @@ -199,7 +227,12 @@ class InstallerTest extends \PHPUnit_Framework_TestCase [DbConfig::CONFIG_KEY, self::$dbConfig], [EncryptConfig::CONFIG_KEY, [EncryptConfig::KEY_ENCRYPTION_KEY => 'encryption_key']] ])); - + $allModules = ['Foo_One' => [], 'Bar_Two' => []]; + $this->moduleLoader->expects($this->any())->method('load')->willReturn($allModules); + $modules = ['Foo_One' => 1, 'Bar_Two' => 1 ]; + $this->deploymentConfig->expects($this->any())->method('getData')->willReturn($modules); + $this->deploymentConfigFactory->expects($this->any())->method('create')->with($modules) + ->willReturn($this->deploymentConfig); $setup = $this->getMock('Magento\Setup\Module\Setup', [], [], '', false); $table = $this->getMock('Magento\Framework\DB\Ddl\Table', [], [], '', false); $connection = $this->getMockForAbstractClass('Magento\Framework\DB\Adapter\AdapterInterface'); @@ -285,6 +318,43 @@ class InstallerTest extends \PHPUnit_Framework_TestCase $this->assertSame(['message' => [$expectedMessage]], $this->object->getInstallInfo()); } + public function testUpdateModulesSequence() + { + $varDir = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); + $varDir->expects($this->exactly(2))->method('getAbsolutePath')->willReturn('/var'); + $this->filesystem + ->expects($this->exactly(2)) + ->method('getDirectoryWrite') + ->willReturn($varDir); + + $allModules = [ + 'Foo_One' => [], + 'Bar_Two' => [], + 'New_Module' => [], + ]; + $this->moduleLoader->expects($this->once())->method('load')->willReturn($allModules); + + $expectedModules = [ + 'Bar_Two' => 0, + 'Foo_One' => 1, + 'New_Module' => 1 + ]; + + $this->config->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true); + $this->deploymentConfigFactory->expects($this->once())->method('create')->with($expectedModules) + ->willReturn($this->deploymentConfig); + + $newObject = $this->createObject(false, false); + $this->configReader->expects($this->once())->method('load') + ->willReturn(['modules' => ['Bar_Two' => 0, 'Foo_One' => 1, 'Old_Module' => 0] ]); + $this->configWriter->expects($this->once())->method('update')->with($this->deploymentConfig); + $this->logger->expects($this->at(0))->method('log')->with('File system cleanup:'); + $this->logger->expects($this->at(1))->method('log') + ->with('The directory \'/var\' doesn\'t exist - skipping cleanup'); + $this->logger->expects($this->at(3))->method('log')->with('Updating modules:'); + $newObject->updateModulesSequence(); + } + public function testUninstall() { $this->config->expects($this->once())->method('isAvailable')->willReturn(false); diff --git a/setup/view/magento/setup/add-database.phtml b/setup/view/magento/setup/add-database.phtml index 89606123cdf98a39f0c62580a489ba9f1ab2b68a..7f3091734e0db60c20ff7f1b4cfc21b3ba0623bd 100644 --- a/setup/view/magento/setup/add-database.phtml +++ b/setup/view/magento/setup/add-database.phtml @@ -42,9 +42,9 @@ </div> <div class="message message-error" - ng-show="testConnection.result.success === undefined && testConnection.result !== undefined" + ng-show="testConnection.failed !== undefined" > - <span class="message-text">Unknown Database Server Host.</span> + <span class="message-text">{{testConnection.failed}}</span> </div> <form diff --git a/setup/view/magento/setup/readiness-check/progress.phtml b/setup/view/magento/setup/readiness-check/progress.phtml index 34ee9207b59a00ace2ddbf7b9eb55a62b12ba49e..275d677b1c8795c019e4122da50dd8274a775de2 100644 --- a/setup/view/magento/setup/readiness-check/progress.phtml +++ b/setup/view/magento/setup/readiness-check/progress.phtml @@ -86,6 +86,58 @@ </div> +<div id="php-rawpost" class="rediness-check-item" ng-show="rawpost.visible"> + + <h3 class="readiness-check-title" ng-hide="version.processed"> + Checking PHP Settings... + </h3> + + <div ng-show="rawpost.processed" ng-switch="rawpost.responseType"> + + <div ng-switch-when="success" ng-init="updateOnSuccess(rawpost)"> + + <span class="readiness-check-icon icon-success-round"></span> + + <div class="readiness-check-content"> + <h3 class="readiness-check-title">PHP Settings Check</h3> + <p> + Your PHP setting is correct. + </p> + </div> + + </div> + + <div class="readiness-check-item" ng-switch-default ng-init="updateOnError(rawpost)"> + + <div class="rediness-check-side"> + <p class="side-title">Need Help?</p> + <a href="http://php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data" target="_blank">PHP Documentation</a> + </div> + + <span class="readiness-check-icon icon-failed-round"></span> + + <div class="readiness-check-content"> + <h3 class="readiness-check-title">PHP Settings Check</h3> + <p> + Your PHP Version is {{rawpost.data.version}}, but always_populate_raw_post_data = {{rawpost.data.ini}}. + <a href="#php-rawpost" ng-click="updateOnExpand(rawpost)"> + <span ng-hide="rawpost.expanded">Show detail</span> + <span ng-show="rawpost.expanded">Hide detail</span> + </a> + </p> + <p ng-show="rawpost.expanded"> + $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will stop the installer from running. + Please open your php.ini file and set always_populate_raw_post_data to -1. + </p> + <p ng-show="rawpost.expanded">If you need more help please call your hosting provider.</p> + </div> + + </div> + + </div> + +</div> + <div id="php-extensions" class="rediness-check-item" ng-show="extensions.visible"> <h3 ng-hide="extensions.processed" class="readiness-check-title">