From f47e46fb9d0750fddc26d50cfc1c5fd97a8386c8 Mon Sep 17 00:00:00 2001 From: Maddy Chellathurai Date: Thu, 12 May 2016 08:40:33 -0500 Subject: [PATCH 01/18] MAGETWO-51929: Web Setup Wizard does not work when Magento is installed in pub - Do not show setup wizard when document root is pub --- .../Backend/Model/Setup/MenuBuilder.php | 48 +++++++++++++++++++ app/code/Magento/Backend/etc/di.xml | 3 ++ .../Magento/Framework/App/DocRoot.php | 47 ++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 app/code/Magento/Backend/Model/Setup/MenuBuilder.php create mode 100644 lib/internal/Magento/Framework/App/DocRoot.php diff --git a/app/code/Magento/Backend/Model/Setup/MenuBuilder.php b/app/code/Magento/Backend/Model/Setup/MenuBuilder.php new file mode 100644 index 0000000000000..76d98a8a79fe8 --- /dev/null +++ b/app/code/Magento/Backend/Model/Setup/MenuBuilder.php @@ -0,0 +1,48 @@ +docRoot = $docRoot; + } + + /** + * Removes 'Web Setup Wizard' from the menu if doc root is pub and no setup url variable is specified. + * + * @param Builder $subject + * @param Menu $menu + * @return Menu + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterGetResult(Builder $subject, Menu $menu) + { + if ($this->docRoot->hasThisSubDir('pub', 'setup')) { + $menu->remove('Magento_Backend::setup_wizard'); + } + return $menu; + } +} diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml index 3009bc4e1fc8c..7eadb69d9b1ed 100644 --- a/app/code/Magento/Backend/etc/di.xml +++ b/app/code/Magento/Backend/etc/di.xml @@ -214,4 +214,7 @@ + + + diff --git a/lib/internal/Magento/Framework/App/DocRoot.php b/lib/internal/Magento/Framework/App/DocRoot.php new file mode 100644 index 0000000000000..c70976cad691d --- /dev/null +++ b/lib/internal/Magento/Framework/App/DocRoot.php @@ -0,0 +1,47 @@ +request = $request; + $this->readFactory = $readFactory; + } + + /** + * Returns true if doc root is pub/ and not BP + * + * @return string + */ + public function hasThisSubDir($dirToCheck, $missingDir) + { + $rootBasePath = $this->request->getServer('DOCUMENT_ROOT'); + $readDirectory = $this->readFactory->create(DirectoryList::ROOT); + return strpos($rootBasePath, $dirToCheck) && !$readDirectory->isExist($rootBasePath + $missingDir); + } +} From 166e034b07fb492eec76d8290d49aa367f137877 Mon Sep 17 00:00:00 2001 From: Maddy Chellathurai Date: Thu, 12 May 2016 09:13:49 -0500 Subject: [PATCH 02/18] MAGETWO-51929: Web Setup Wizard does not work when Magento is installed in pub - Static fixes --- lib/internal/Magento/Framework/App/DocRoot.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/App/DocRoot.php b/lib/internal/Magento/Framework/App/DocRoot.php index c70976cad691d..5c62fe87e61c9 100644 --- a/lib/internal/Magento/Framework/App/DocRoot.php +++ b/lib/internal/Magento/Framework/App/DocRoot.php @@ -28,15 +28,20 @@ class DocRoot * @param RequestInterface $request * @param ReadFactory $readFactory */ - public function __construct(RequestInterface $request, ReadFactory $readFactory) { + public function __construct(RequestInterface $request, ReadFactory $readFactory) + { $this->request = $request; $this->readFactory = $readFactory; } + /** * Returns true if doc root is pub/ and not BP * - * @return string + * @param $dirToCheck + * @param $missingDir + * + * @return bool */ public function hasThisSubDir($dirToCheck, $missingDir) { From 95ce85ba4f880c8efe97f3a06c338c1214d2a219 Mon Sep 17 00:00:00 2001 From: Maddy Chellathurai Date: Thu, 12 May 2016 09:25:19 -0500 Subject: [PATCH 03/18] MAGETWO-51929: Web Setup Wizard does not work when Magento is installed in pub - Static fixes --- lib/internal/Magento/Framework/App/DocRoot.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/App/DocRoot.php b/lib/internal/Magento/Framework/App/DocRoot.php index 5c62fe87e61c9..39a71f7e9b86a 100644 --- a/lib/internal/Magento/Framework/App/DocRoot.php +++ b/lib/internal/Magento/Framework/App/DocRoot.php @@ -34,12 +34,11 @@ public function __construct(RequestInterface $request, ReadFactory $readFactory) $this->readFactory = $readFactory; } - /** * Returns true if doc root is pub/ and not BP * - * @param $dirToCheck - * @param $missingDir + * @param string $dirToCheck + * @param string $missingDir * * @return bool */ From 5d8e3f38b610d8861804450db19bcd5fa2f9aea0 Mon Sep 17 00:00:00 2001 From: Maddy Chellathurai Date: Wed, 18 May 2016 14:38:15 -0500 Subject: [PATCH 04/18] MAGETWO-51929: Web Setup Wizard does not work when Magento is installed in pub - CR comments --- .../Backend/Model/Setup/MenuBuilder.php | 15 ++++--- .../Test/Unit/Model/MenuBuilderTest.php | 42 +++++++++++++++++++ .../App/{DocRoot.php => DocRootLocator.php} | 9 ++-- .../App/Test/Unit/DocRootLocatorTest.php | 41 ++++++++++++++++++ 4 files changed, 93 insertions(+), 14 deletions(-) create mode 100644 app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php rename lib/internal/Magento/Framework/App/{DocRoot.php => DocRootLocator.php} (79%) create mode 100644 lib/internal/Magento/Framework/App/Test/Unit/DocRootLocatorTest.php diff --git a/app/code/Magento/Backend/Model/Setup/MenuBuilder.php b/app/code/Magento/Backend/Model/Setup/MenuBuilder.php index 76d98a8a79fe8..70821e6ea85b5 100644 --- a/app/code/Magento/Backend/Model/Setup/MenuBuilder.php +++ b/app/code/Magento/Backend/Model/Setup/MenuBuilder.php @@ -7,27 +7,26 @@ use Magento\Backend\Model\Menu; use Magento\Backend\Model\Menu\Builder; -use Magento\Framework\App\DocRoot; +use Magento\Framework\App\DocRootLocator; /** * Plugin class to remove web setup wizard from menu if application root is pub/ and no setup url variable is specified. */ class MenuBuilder { - /** - * @var DocRoot + * @var DocRootLocator */ - protected $docRoot; + protected $docRootLocator; /** * MenuBuilder constructor. * - * @param DocRoot $docRoot + * @param DocRootLocator $docRootLocator */ - public function __construct(DocRoot $docRoot) + public function __construct(DocRootLocator $docRootLocator) { - $this->docRoot = $docRoot; + $this->docRootLocator = $docRootLocator; } /** @@ -40,7 +39,7 @@ public function __construct(DocRoot $docRoot) */ public function afterGetResult(Builder $subject, Menu $menu) { - if ($this->docRoot->hasThisSubDir('pub', 'setup')) { + if ($this->docRootLocator->isPub()) { $menu->remove('Magento_Backend::setup_wizard'); } return $menu; diff --git a/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php b/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php new file mode 100644 index 0000000000000..677c7f77e0be4 --- /dev/null +++ b/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php @@ -0,0 +1,42 @@ +getMock('\Magento\Framework\App\DocRootLocator', [], [], '', false); + $docRootLocator->expects($this->once())->method('isPub')->willReturn($isPub); + $model = new MenuBuilder($docRootLocator); + /** @var \Magento\Backend\Model\Menu $menu */ + $menu = $this->getMock('\Magento\Backend\Model\Menu', [], [], '', false); + $menu->expects($this->exactly($times))->method('remove')->willReturn(true); + + /** @var \Magento\Backend\Model\Menu\Builder $menuBuilder */ + $menuBuilder = $this->getMock('\Magento\Backend\Model\Menu\Builder', [], [], '', false); + + $this->assertInstanceOf( + '\Magento\Backend\Model\Menu', + $model->afterGetResult($menuBuilder, $menu) + ); + } + + public function afterGetResultDataProvider() + { + return [[true, 1], [false, 0],]; + } +} diff --git a/lib/internal/Magento/Framework/App/DocRoot.php b/lib/internal/Magento/Framework/App/DocRootLocator.php similarity index 79% rename from lib/internal/Magento/Framework/App/DocRoot.php rename to lib/internal/Magento/Framework/App/DocRootLocator.php index 39a71f7e9b86a..39d40a6f1a00e 100644 --- a/lib/internal/Magento/Framework/App/DocRoot.php +++ b/lib/internal/Magento/Framework/App/DocRootLocator.php @@ -12,7 +12,7 @@ /** * This class calculates if document root is set to pub */ -class DocRoot +class DocRootLocator { /** * @var RequestInterface @@ -37,15 +37,12 @@ public function __construct(RequestInterface $request, ReadFactory $readFactory) /** * Returns true if doc root is pub/ and not BP * - * @param string $dirToCheck - * @param string $missingDir - * * @return bool */ - public function hasThisSubDir($dirToCheck, $missingDir) + public function isPub() { $rootBasePath = $this->request->getServer('DOCUMENT_ROOT'); $readDirectory = $this->readFactory->create(DirectoryList::ROOT); - return strpos($rootBasePath, $dirToCheck) && !$readDirectory->isExist($rootBasePath + $missingDir); + return strpos($rootBasePath, 'pub') && !$readDirectory->isExist($rootBasePath . 'setup'); } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DocRootLocatorTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DocRootLocatorTest.php new file mode 100644 index 0000000000000..59ec0721c9204 --- /dev/null +++ b/lib/internal/Magento/Framework/App/Test/Unit/DocRootLocatorTest.php @@ -0,0 +1,41 @@ +getMock('\Magento\Framework\App\Request\Http', [], [], '', false); + $request->expects($this->once())->method('getServer')->willReturn($path); + $reader = $this->getMock('\Magento\Framework\Filesystem\Directory\Read', [], [], '', false); + $reader->expects($this->any())->method('isExist')->willReturn($isExist); + $readFactory = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false); + $readFactory->expects($this->once())->method('create')->willReturn($reader); + $model = new DocRootLocator($request, $readFactory); + $this->assertSame($result, $model->isPub()); + } + + public function isPubDataProvider() + { + return [ + ['/some/path/to/root', false, false], + ['/some/path/to/root', true, false], + ['/some/path/to/pub', false, true], + ['/some/path/to/pub', true, false], + ]; + } +} From 503643c342720dc02f7d6a1d4b3c812a78597115 Mon Sep 17 00:00:00 2001 From: Maddy Chellathurai Date: Wed, 25 May 2016 16:22:56 -0500 Subject: [PATCH 05/18] MAGETWO-53474: [Github] Caches Aren't Enabled by Default on RC1 with Composer when Upgrading via CLI - Moving logic to re-enable cache to setup:upgrade --- .../Magento/Framework/Code/GeneratedFiles.php | 2 ++ .../Setup/Console/Command/UpgradeCommand.php | 26 +++++++++++++++++++ .../Magento/Setup/Model/Cron/JobUpgrade.php | 22 ---------------- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/lib/internal/Magento/Framework/Code/GeneratedFiles.php b/lib/internal/Magento/Framework/Code/GeneratedFiles.php index 99fb41c30a7c3..ec6e43b8c67f1 100644 --- a/lib/internal/Magento/Framework/Code/GeneratedFiles.php +++ b/lib/internal/Magento/Framework/Code/GeneratedFiles.php @@ -52,6 +52,7 @@ public function __construct(DirectoryList $directoryList, WriteFactory $writeFac public function regenerate() { if ($this->write->isExist(self::REGENERATE_FLAG)) { + //TODO: to be removed in scope of MAGETWO-53476 //clean cache $deploymentConfig = $this->directoryList->getPath(DirectoryList::CONFIG); $configPool = new ConfigFilePool(); @@ -59,6 +60,7 @@ public function regenerate() if ($this->write->isExist($this->write->getRelativePath($envPath))) { $this->saveCacheStatus($envPath); } + //TODO: Till here $cachePath = $this->write->getRelativePath($this->directoryList->getPath(DirectoryList::CACHE)); $generationPath = $this->write->getRelativePath($this->directoryList->getPath(DirectoryList::GENERATION)); $diPath = $this->write->getRelativePath($this->directoryList->getPath(DirectoryList::DI)); diff --git a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php index c4ca7c833394b..68c54f4f64828 100644 --- a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php +++ b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php @@ -5,10 +5,13 @@ */ namespace Magento\Setup\Console\Command; +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Backend\Console\Command\AbstractCacheManageCommand; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Setup\ConsoleLogger; use Magento\Setup\Model\InstallerFactory; use Magento\Setup\Model\ObjectManagerProvider; +use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -94,5 +97,28 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$keepGenerated) { $output->writeln('Please re-run Magento compile command'); } + + //TODO: to be removed in scope of MAGETWO-53476 + $writeFactory = $objectManager->get('\Magento\Framework\Filesystem\Directory\WriteFactory'); + $write = $writeFactory->create(BP); + /** @var \Magento\Framework\App\Filesystem\DirectoryList $dirList */ + $dirList = $objectManager->get('\Magento\Framework\App\Filesystem\DirectoryList'); + + $pathToCacheStatus = $write->getRelativePath($dirList->getPath(DirectoryList::VAR_DIR) . '/.cachestates.json'); + + if ($write->isExist($pathToCacheStatus)) { + $params = array_keys(json_decode($write->readFile($pathToCacheStatus), true)); + $command = $this->getApplication()->find('cache:enable'); + + $arguments = ['command' => 'cache:enable', AbstractCacheManageCommand::INPUT_KEY_TYPES => $params ]; + $returnCode = $command->run(new ArrayInput($arguments), $output); + + $write->delete($pathToCacheStatus); + if (isset($returnCode) && $returnCode > 0) { + $output->writeln(' Error occured during upgrade'); + return \Magento\Framework\Console\Cli::RETURN_FAILURE; + } + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; + } } } diff --git a/setup/src/Magento/Setup/Model/Cron/JobUpgrade.php b/setup/src/Magento/Setup/Model/Cron/JobUpgrade.php index 490af5576d090..ef2e12606bd04 100644 --- a/setup/src/Magento/Setup/Model/Cron/JobUpgrade.php +++ b/setup/src/Magento/Setup/Model/Cron/JobUpgrade.php @@ -5,8 +5,6 @@ */ namespace Magento\Setup\Model\Cron; -use Magento\Framework\App\Filesystem\DirectoryList; -use Magento\Framework\Filesystem; use Magento\Setup\Console\Command\AbstractSetupCommand; use Magento\Setup\Model\ObjectManagerProvider; use Symfony\Component\Console\Input\ArrayInput; @@ -72,26 +70,6 @@ public function execute() ); $this->params['command'] = 'setup:upgrade'; $this->command->run(new ArrayInput($this->params), $this->output); - - /** - * @var \Magento\Framework\Filesystem\Directory\WriteFactory $writeFactory - */ - $writeFactory = $this->objectManager->get('\Magento\Framework\Filesystem\Directory\WriteFactory'); - $write = $writeFactory->create(BP); - $dirList = $this->objectManager->get('\Magento\Framework\App\Filesystem\DirectoryList'); - $pathToCacheStatus = $write->getRelativePath( - $dirList->getPath(DirectoryList::VAR_DIR) . '/.cachestates.json' - ); - - if ($write->isExist($pathToCacheStatus)) { - $params = array_keys(json_decode($write->readFile($pathToCacheStatus), true)); - - $this->queue->addJobs( - [['name' => JobFactory::JOB_ENABLE_CACHE, 'params' => [implode(' ', $params)]]] - ); - $write->delete($pathToCacheStatus); - } - } catch (\Exception $e) { $this->status->toggleUpdateError(true); throw new \RuntimeException(sprintf('Could not complete %s successfully: %s', $this, $e->getMessage())); From 960ac5982ded3eeef02f43df446f09672861fc26 Mon Sep 17 00:00:00 2001 From: Maddy Chellathurai Date: Thu, 26 May 2016 09:21:02 -0500 Subject: [PATCH 06/18] MAGETWO-53474: [Github] Caches Aren't Enabled by Default on RC1 with Composer when Upgrading via CLI - Updating tests. --- .../Setup/Console/Command/UpgradeCommand.php | 4 +-- .../Console/Command/UpgradeCommandTest.php | 24 ++++++++++++----- .../Test/Unit/Model/Cron/JobUpgradeTest.php | 26 +------------------ 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php index 68c54f4f64828..07453181a886d 100644 --- a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php +++ b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php @@ -99,10 +99,10 @@ protected function execute(InputInterface $input, OutputInterface $output) } //TODO: to be removed in scope of MAGETWO-53476 - $writeFactory = $objectManager->get('\Magento\Framework\Filesystem\Directory\WriteFactory'); + $writeFactory = $objectManager->get('Magento\Framework\Filesystem\Directory\WriteFactory'); $write = $writeFactory->create(BP); /** @var \Magento\Framework\App\Filesystem\DirectoryList $dirList */ - $dirList = $objectManager->get('\Magento\Framework\App\Filesystem\DirectoryList'); + $dirList = $objectManager->get('Magento\Framework\App\Filesystem\DirectoryList'); $pathToCacheStatus = $write->getRelativePath($dirList->getPath(DirectoryList::VAR_DIR) . '/.cachestates.json'); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php index 1b493e9cf330c..9066201ace7b3 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php @@ -20,12 +20,6 @@ public function testExecute() $state = $this->getMock('Magento\Framework\App\State', [], [], '', false); $state->expects($this->once())->method('setAreaCode')->with('setup'); $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); - $objectManager->expects($this->exactly(2)) - ->method('get') - ->will($this->returnValueMap([ - ['Magento\Framework\App\State', $state], - ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader], - ])); $objectManager->expects($this->once())->method('configure'); $state->expects($this->once())->method('setAreaCode')->with('setup'); $installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false); @@ -33,6 +27,24 @@ public function testExecute() $installer->expects($this->at(1))->method('installSchema'); $installer->expects($this->at(2))->method('installDataFixtures'); $installerFactory->expects($this->once())->method('create')->willReturn($installer); + + $pathToCacheStatus = '/path/to/cachefile'; + $writeFactory = $this->getMock('\Magento\Framework\Filesystem\Directory\WriteFactory', [], [], '', false); + $write = $this->getMock('\Magento\Framework\Filesystem\Directory\Write', [], [], '', false); + $write->expects($this->once())->method('isExist')->with('/path/to/cachefile')->willReturn(false); + $write->expects($this->once())->method('getRelativePath')->willReturn($pathToCacheStatus); + + $writeFactory->expects($this->once())->method('create')->willReturn($write); + $directoryList = $this->getMock('\Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $objectManager->expects($this->exactly(4)) + ->method('get') + ->will($this->returnValueMap([ + ['Magento\Framework\App\State', $state], + ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader], + ['Magento\Framework\Filesystem\Directory\WriteFactory', $writeFactory], + ['Magento\Framework\App\Filesystem\DirectoryList', $directoryList], + ])); + $commandTester = new CommandTester(new UpgradeCommand($installerFactory, $objectManagerProvider)); $commandTester->execute([]); } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobUpgradeTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobUpgradeTest.php index a9d8ac8dbde14..bcd9e7ca5785d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobUpgradeTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobUpgradeTest.php @@ -12,7 +12,7 @@ class JobUpgradeTest extends \PHPUnit_Framework_TestCase public function testExecute() { $queue = $this->getMock('Magento\Setup\Model\Cron\Queue', [], [], '', false); - $queue->expects($this->exactly(3))->method('addJobs'); + $queue->expects($this->exactly(2))->method('addJobs'); $command = $this->getMock('Magento\Setup\Console\Command\UpgradeCommand', [], [], '', false); $command->expects($this->once())->method('run'); $status = $this->getMock('Magento\Setup\Model\Cron\Status', [], [], '', false); @@ -21,30 +21,6 @@ public function testExecute() $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', ['get'], [], '', false); $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); - $cleanupFiles = $this->getMock('\Magento\Framework\App\State\CleanupFiles', [], [], '', false); - $cache = $this->getMock('\Magento\Framework\App\Cache', [], [], '', false); - - $pathToCacheStatus = '/path/to/cachefile'; - $writeFactory = $this->getMock('\Magento\Framework\Filesystem\Directory\WriteFactory', [], [], '', false); - $write = $this->getMock('\Magento\Framework\Filesystem\Directory\Write', [], [], '', false); - $write->expects($this->once())->method('isExist')->with('/path/to/cachefile')->willReturn(true); - $write->expects($this->once())->method('readFile')->with('/path/to/cachefile')->willReturn( - '{"cacheOne":1,"cacheTwo":1,"cacheThree":1}' - ); - $write->expects($this->once())->method('delete')->with('/path/to/cachefile')->willReturn(true); - $write->expects($this->once())->method('getRelativePath')->willReturn($pathToCacheStatus); - - $writeFactory->expects($this->once())->method('create')->willReturn($write); - $directoryList = $this->getMock('\Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); - $directoryList->expects($this->once())->method('getPath')->willReturn('/some/full/path' . $pathToCacheStatus); - - $objectManager->expects($this->any())->method('get')->will($this->returnValueMap([ - ['\Magento\Framework\Filesystem\Directory\WriteFactory', $writeFactory], - ['\Magento\Framework\App\Filesystem\DirectoryList', $directoryList], - ['\Magento\Framework\App\State\CleanupFiles', $cleanupFiles], - ['\Magento\Framework\App\Cache', $cache], - ])); - $jobUpgrade = new JobUpgrade( $command, $objectManagerProvider, From 497b8f89333bca577dc2ccbdc931c461d8b923e5 Mon Sep 17 00:00:00 2001 From: Maddy Chellathurai Date: Fri, 27 May 2016 08:53:30 -0500 Subject: [PATCH 07/18] MAGETWO-53474: [Github] Caches Aren't Enabled by Default on RC1 with Composer when Upgrading via CLI - CR comments --- .../Setup/Console/Command/UpgradeCommand.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php index 07453181a886d..34b74e4493b80 100644 --- a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php +++ b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php @@ -98,7 +98,18 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('Please re-run Magento compile command'); } - //TODO: to be removed in scope of MAGETWO-53476 + return $this->doSomething($objectManager); + } + + /** + * Enables cache if cachestates exists + * TODO: to be removed in scope of MAGETWO-53476 + * + * @param \Magento\Framework\ObjectManagerInterface $objectManager + * @return int + */ + private function doSomething($objectManager) + { $writeFactory = $objectManager->get('Magento\Framework\Filesystem\Directory\WriteFactory'); $write = $writeFactory->create(BP); /** @var \Magento\Framework\App\Filesystem\DirectoryList $dirList */ From f375681c1b7025b3df43d0d9f1c4f11d5d9f3a30 Mon Sep 17 00:00:00 2001 From: Maddy Chellathurai Date: Fri, 27 May 2016 08:58:09 -0500 Subject: [PATCH 08/18] MAGETWO-53474: [Github] Caches Aren't Enabled by Default on RC1 with Composer when Upgrading via CLI - CR comments --- setup/src/Magento/Setup/Console/Command/UpgradeCommand.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php index 34b74e4493b80..50c7daa892ca0 100644 --- a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php +++ b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php @@ -98,7 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('Please re-run Magento compile command'); } - return $this->doSomething($objectManager); + return $this->enableCaches($objectManager, $output); } /** @@ -106,9 +106,10 @@ protected function execute(InputInterface $input, OutputInterface $output) * TODO: to be removed in scope of MAGETWO-53476 * * @param \Magento\Framework\ObjectManagerInterface $objectManager + * @param \Symfony\Component\Console\Output\OutputInterface $output * @return int */ - private function doSomething($objectManager) + private function enableCaches($objectManager, $output) { $writeFactory = $objectManager->get('Magento\Framework\Filesystem\Directory\WriteFactory'); $write = $writeFactory->create(BP); From c840f1a72de69de84d746947dec573bac887037d Mon Sep 17 00:00:00 2001 From: Maddy Chellathurai Date: Fri, 27 May 2016 09:06:49 -0500 Subject: [PATCH 09/18] MAGETWO-53474: [Github] Caches Aren't Enabled by Default on RC1 with Composer when Upgrading via CLI - CR comments --- setup/src/Magento/Setup/Console/Command/UpgradeCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php index 50c7daa892ca0..d5e330c551ec3 100644 --- a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php +++ b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php @@ -130,7 +130,7 @@ private function enableCaches($objectManager, $output) $output->writeln(' Error occured during upgrade'); return \Magento\Framework\Console\Cli::RETURN_FAILURE; } - return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } From f5b6382d589137cc2713b689e515f7ad78f50ad7 Mon Sep 17 00:00:00 2001 From: Maddy Chellathurai Date: Tue, 31 May 2016 11:00:03 -0500 Subject: [PATCH 10/18] MAGETWO-53689: Integration tests on Travis CI are very close to exceed time limit - splitting into 3 sets --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index becf280a3a2b3..bc5ccd804667b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ php: env: global: - COMPOSER_BIN_DIR=~/bin - - INTEGRATION_SETS=2 + - INTEGRATION_SETS=3 matrix: - TEST_SUITE=unit - TEST_SUITE=integration INTEGRATION_INDEX=1 From 40f26a175fcf331fee0abdb8a18303e6dcd0da29 Mon Sep 17 00:00:00 2001 From: Maddy Chellathurai Date: Tue, 31 May 2016 11:30:32 -0500 Subject: [PATCH 11/18] MAGETWO-53689: Integration tests on Travis CI are very close to exceed time limit - splitting into 3 sets --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bc5ccd804667b..a82e42481c4e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ env: - TEST_SUITE=unit - TEST_SUITE=integration INTEGRATION_INDEX=1 - TEST_SUITE=integration INTEGRATION_INDEX=2 + - TEST_SUITE=integration INTEGRATION_INDEX=3 - TEST_SUITE=static cache: apt: true From 89cca73eba2f0228ee5dc2c7fc92ab4ee413850a Mon Sep 17 00:00:00 2001 From: Paul Lewis Date: Tue, 31 May 2016 17:51:09 -0500 Subject: [PATCH 12/18] MAGETWO-51926: All Integration Tests for Elasticsearch are Skipped - Correct date format in integration test --- .../Magento/Framework/Search/Adapter/Mysql/AdapterTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php index fda3851989ea8..b0f8931236c65 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php @@ -407,7 +407,7 @@ public function testAdvancedSearchDateField($rangeFilter, $expectedRecordsCount) { array_walk($rangeFilter, function (&$item) { if (!empty($item)) { - $item = gmdate('c', strtotime($item)) . 'Z'; + $item = gmdate('c', strtotime($item)); } }); $this->requestBuilder->bind('date.from', $rangeFilter['from']); From 9026adaec352b4ebe54738c0ce6fae3b8de3f07b Mon Sep 17 00:00:00 2001 From: Paul Lewis Date: Wed, 1 Jun 2016 17:02:56 -0500 Subject: [PATCH 13/18] MAGETWO-51926: All Integration Tests for Elasticsearch are Skipped - Correct date format in integration test --- .../Magento/Framework/Search/Adapter/Mysql/AdapterTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php index b0f8931236c65..397f15b0c5c8f 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php @@ -407,7 +407,8 @@ public function testAdvancedSearchDateField($rangeFilter, $expectedRecordsCount) { array_walk($rangeFilter, function (&$item) { if (!empty($item)) { - $item = gmdate('c', strtotime($item)); + $item = gmdate('c', strtotime($item)) . 'Z'; + $item = str_replace('+00:00', '', $item); } }); $this->requestBuilder->bind('date.from', $rangeFilter['from']); From d9b59fa628d1fa7f2b5ed51bc16efd23ce4ed7a1 Mon Sep 17 00:00:00 2001 From: Ankur Kaneria Date: Fri, 3 Jun 2016 00:29:16 -0500 Subject: [PATCH 14/18] MAGETWO-51926: All Integration Tests for Elasticsearch are Skipped - Updates based on code review --- .../Framework/Search/Adapter/Mysql/AdapterTest.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php index 397f15b0c5c8f..2df0a3e881c67 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php @@ -405,12 +405,6 @@ public function testCustomFilterableAttribute() */ public function testAdvancedSearchDateField($rangeFilter, $expectedRecordsCount) { - array_walk($rangeFilter, function (&$item) { - if (!empty($item)) { - $item = gmdate('c', strtotime($item)) . 'Z'; - $item = str_replace('+00:00', '', $item); - } - }); $this->requestBuilder->bind('date.from', $rangeFilter['from']); $this->requestBuilder->bind('date.to', $rangeFilter['to']); $this->requestBuilder->setRequestName('advanced_search_date_field'); @@ -422,10 +416,10 @@ public function testAdvancedSearchDateField($rangeFilter, $expectedRecordsCount) public function dateDataProvider() { return [ - [['from' => '2000-01-01', 'to' => '2000-01-01'], 1], //Y-m-d - [['from' => '2000-01-01', 'to' => ''], 1], - [['from' => '1999-12-31', 'to' => '2000-01-01'], 1], - [['from' => '2000-02-01', 'to' => ''], 0], + [['from' => '2000-01-01T00:00:00Z', 'to' => '2000-01-01T00:00:00Z'], 1], //Y-m-d + [['from' => '2000-01-01T00:00:00Z', 'to' => ''], 1], + [['from' => '1999-12-31T00:00:00Z', 'to' => '2000-01-01T00:00:00Z'], 1], + [['from' => '2000-02-01T00:00:00Z', 'to' => ''], 0], ]; } } From c100f06e639b10f99f3d695381fa1c3191f57124 Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Mon, 6 Jun 2016 11:55:08 -0500 Subject: [PATCH 15/18] MAGETWO-53003: System Upgrade Test does not support RC version --- .../Upgrade/Test/TestCase/UpgradeSystemTest.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php b/dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php index 50afbd48e4151..78f8d4d67743b 100644 --- a/dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php +++ b/dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php @@ -73,8 +73,19 @@ public function test( ); $version = $upgrade['upgradeVersion']; - if (preg_match('/^[0-9].[0-9].[0-9]/', $version, $out)) { + $normalVersion = '(0|[1-9]\d*)'; + $preReleaseVersion = '((0(?!\d+(\.|\+|$))|[1-9A-Za-z])[0-9A-Za-z-]*)'; + $buildVersion = '([0-9A-Za-z][0-9A-Za-z-]*)'; + $versionPattern = "/^$normalVersion(\\.$normalVersion){2}" + . "(-$preReleaseVersion(\\.$preReleaseVersion)*)?" + . "(\\+$buildVersion(\\.$buildVersion)*)?$/"; + + if (preg_match($versionPattern, $version, $out)) { $version = array_shift($out); + } else { + $this->fail( + "Provided version format does not comply with semantic versioning specification. Got '{$version}'" + ); } // Authenticate in admin area From b0ee7e0e8f727b6a09fe76b074a391c9ae08b5ef Mon Sep 17 00:00:00 2001 From: Alexander Paliarush Date: Mon, 6 Jun 2016 17:06:12 -0500 Subject: [PATCH 16/18] MAGETWO-53003: System Upgrade Test does not support RC version --- .../Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php b/dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php index 78f8d4d67743b..c6f9d4fd7f15f 100644 --- a/dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php +++ b/dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php @@ -73,12 +73,13 @@ public function test( ); $version = $upgrade['upgradeVersion']; + $suffix = "( (CE|EE))$"; $normalVersion = '(0|[1-9]\d*)'; - $preReleaseVersion = '((0(?!\d+(\.|\+|$))|[1-9A-Za-z])[0-9A-Za-z-]*)'; + $preReleaseVersion = "((0(?!\\d+(\\.|\\+|{$suffix}))|[1-9A-Za-z])[0-9A-Za-z-]*)"; $buildVersion = '([0-9A-Za-z][0-9A-Za-z-]*)'; - $versionPattern = "/^$normalVersion(\\.$normalVersion){2}" - . "(-$preReleaseVersion(\\.$preReleaseVersion)*)?" - . "(\\+$buildVersion(\\.$buildVersion)*)?$/"; + $versionPattern = "/^{$normalVersion}(\\.{$normalVersion}){2}" + . "(-{$preReleaseVersion}(\\.{$preReleaseVersion})*)?" + . "(\\+{$buildVersion}(\\.{$buildVersion})*)?{$suffix}/"; if (preg_match($versionPattern, $version, $out)) { $version = array_shift($out); From 2f9ccf08f7a1b50762a089c905644ead9f97f10f Mon Sep 17 00:00:00 2001 From: Ankur Kaneria Date: Wed, 8 Jun 2016 13:39:32 -0500 Subject: [PATCH 17/18] MAGETWO-51929: [Github] [Deferred for 2.1 GA] Web Setup Wizard does not work when Magento is installed in pub #4159 - Updates based on review comments - Moved MenuBuilder plugin to adminhtml/di.xml - Updated DocRootLocator logic to look for "/pub" at the end of the base path --- app/code/Magento/Backend/etc/adminhtml/di.xml | 3 +++ app/code/Magento/Backend/etc/di.xml | 3 --- lib/internal/Magento/Framework/App/DocRootLocator.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Backend/etc/adminhtml/di.xml b/app/code/Magento/Backend/etc/adminhtml/di.xml index fa327f645eb81..fcf2cc02e9fb9 100644 --- a/app/code/Magento/Backend/etc/adminhtml/di.xml +++ b/app/code/Magento/Backend/etc/adminhtml/di.xml @@ -138,4 +138,7 @@ false + + + diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml index 9b282a65a479d..7307bbe09f1b4 100644 --- a/app/code/Magento/Backend/etc/di.xml +++ b/app/code/Magento/Backend/etc/di.xml @@ -214,7 +214,4 @@ - - - diff --git a/lib/internal/Magento/Framework/App/DocRootLocator.php b/lib/internal/Magento/Framework/App/DocRootLocator.php index 39d40a6f1a00e..23be6997202b0 100644 --- a/lib/internal/Magento/Framework/App/DocRootLocator.php +++ b/lib/internal/Magento/Framework/App/DocRootLocator.php @@ -43,6 +43,6 @@ public function isPub() { $rootBasePath = $this->request->getServer('DOCUMENT_ROOT'); $readDirectory = $this->readFactory->create(DirectoryList::ROOT); - return strpos($rootBasePath, 'pub') && !$readDirectory->isExist($rootBasePath . 'setup'); + return (substr($rootBasePath, -strlen('/pub')) === '/pub') && !$readDirectory->isExist($rootBasePath . 'setup'); } } From 4c9841e743f111261c824e5fc06340241d4344f5 Mon Sep 17 00:00:00 2001 From: Ankur Kaneria Date: Wed, 8 Jun 2016 13:52:53 -0500 Subject: [PATCH 18/18] MAGETWO-53474: [Github] Caches Aren't Enabled by Default on RC1 with Composer when Upgrading via CLI - Update based on review. - Added returned error code to logged message. --- setup/src/Magento/Setup/Console/Command/UpgradeCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php index d5e330c551ec3..17d86ef9bad58 100644 --- a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php +++ b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php @@ -127,7 +127,8 @@ private function enableCaches($objectManager, $output) $write->delete($pathToCacheStatus); if (isset($returnCode) && $returnCode > 0) { - $output->writeln(' Error occured during upgrade'); + $message = ' Error occured during upgrade. Error code: ' . $returnCode . ''; + $output->writeln($message); return \Magento\Framework\Console\Cli::RETURN_FAILURE; } }