From 1f79f01ee22e3a40debd06a5ac4cf3ec237ded58 Mon Sep 17 00:00:00 2001 From: Olga Kopylova Date: Wed, 9 Mar 2016 13:37:51 -0600 Subject: [PATCH 01/17] MAGETWO-46966: [Github] setup/*.xml Config Files Not Read During Setup #2725 - moved events to base area --- .../Magento/CatalogUrlRewrite/etc/setup/events.xml | 12 ------------ .../Magento/CmsUrlRewrite/etc/{setup => }/events.xml | 0 2 files changed, 12 deletions(-) delete mode 100644 app/code/Magento/CatalogUrlRewrite/etc/setup/events.xml rename app/code/Magento/CmsUrlRewrite/etc/{setup => }/events.xml (100%) diff --git a/app/code/Magento/CatalogUrlRewrite/etc/setup/events.xml b/app/code/Magento/CatalogUrlRewrite/etc/setup/events.xml deleted file mode 100644 index b09be7f9dc0dd..0000000000000 --- a/app/code/Magento/CatalogUrlRewrite/etc/setup/events.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - diff --git a/app/code/Magento/CmsUrlRewrite/etc/setup/events.xml b/app/code/Magento/CmsUrlRewrite/etc/events.xml similarity index 100% rename from app/code/Magento/CmsUrlRewrite/etc/setup/events.xml rename to app/code/Magento/CmsUrlRewrite/etc/events.xml From 71a4ba782a4d56624d62be46e0f77e2cf762b94a Mon Sep 17 00:00:00 2001 From: Olga Kopylova Date: Wed, 9 Mar 2016 15:06:07 -0600 Subject: [PATCH 02/17] MAGETWO-46966: [Github] setup/*.xml Config Files Not Read During Setup #2725 - removed unnecessary duplicated observer configuration --- .../Magento/CmsUrlRewrite/etc/adminhtml/events.xml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 app/code/Magento/CmsUrlRewrite/etc/adminhtml/events.xml diff --git a/app/code/Magento/CmsUrlRewrite/etc/adminhtml/events.xml b/app/code/Magento/CmsUrlRewrite/etc/adminhtml/events.xml deleted file mode 100644 index eb6c3bf239d41..0000000000000 --- a/app/code/Magento/CmsUrlRewrite/etc/adminhtml/events.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - From 268680876bc27dbc38ae681dfe46ac713f968fb3 Mon Sep 17 00:00:00 2001 From: Olga Kopylova Date: Wed, 16 Mar 2016 12:34:26 -0500 Subject: [PATCH 03/17] MAGETWO-46966: [Github] setup/*.xml Config Files Not Read During Setup #2725 - fixed stores getter --- app/code/Magento/Cms/Model/Page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Cms/Model/Page.php b/app/code/Magento/Cms/Model/Page.php index b248ad835d028..513338376ca3c 100644 --- a/app/code/Magento/Cms/Model/Page.php +++ b/app/code/Magento/Cms/Model/Page.php @@ -91,7 +91,7 @@ public function noRoutePage() */ public function getStores() { - return $this->hasData('stores') ? $this->getData('stores') : $this->getData('store_id'); + return $this->hasData('stores') ? $this->getData('stores') : [$this->getData('store_id')]; } /** From 0d4b28738c2154b6a8a8b1280a42ee8197a08f9c Mon Sep 17 00:00:00 2001 From: Olga Kopylova Date: Wed, 16 Mar 2016 17:34:17 -0500 Subject: [PATCH 04/17] MAGETWO-46966: [Github] setup/*.xml Config Files Not Read During Setup #2725 - fixed stores getter --- app/code/Magento/Cms/Model/Page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Cms/Model/Page.php b/app/code/Magento/Cms/Model/Page.php index 513338376ca3c..8a65264945671 100644 --- a/app/code/Magento/Cms/Model/Page.php +++ b/app/code/Magento/Cms/Model/Page.php @@ -91,7 +91,7 @@ public function noRoutePage() */ public function getStores() { - return $this->hasData('stores') ? $this->getData('stores') : [$this->getData('store_id')]; + return $this->hasData('stores') ? $this->getData('stores') : (array)$this->getData('store_id'); } /** From 22fb9cd2e163c4915d4554b07391b9963424a36d Mon Sep 17 00:00:00 2001 From: Paul Lewis Date: Mon, 21 Mar 2016 14:22:28 -0500 Subject: [PATCH 05/17] MAGETWO-50696: Cannot install Magento and run integration tests on Windows - Added check for Windows if directory doesn't have executable bit - Added unit test --- .../Framework/Setup/FilePermissions.php | 27 +++++- .../Setup/Test/Unit/FilePermissionsTest.php | 92 ++++++++++++++++++- 2 files changed, 112 insertions(+), 7 deletions(-) diff --git a/lib/internal/Magento/Framework/Setup/FilePermissions.php b/lib/internal/Magento/Framework/Setup/FilePermissions.php index e70e583c27114..a315fd3013d60 100644 --- a/lib/internal/Magento/Framework/Setup/FilePermissions.php +++ b/lib/internal/Magento/Framework/Setup/FilePermissions.php @@ -10,6 +10,7 @@ use Magento\Framework\Backup\Filesystem\Iterator\Filter; use Magento\Framework\Filesystem; use Magento\Framework\Filesystem\Driver\File; +use Magento\Framework\OsInfo; class FilePermissions { @@ -63,19 +64,27 @@ class FilePermissions */ protected $nonWritablePathsInDirectories = []; + /** + * @var \Magento\Framework\OsInfo + */ + protected $osInfo; + /** * @param Filesystem $filesystem * @param DirectoryList $directoryList * @param File $driverFile + * @param OsInfo $osInfo */ public function __construct( Filesystem $filesystem, DirectoryList $directoryList, - File $driverFile + File $driverFile, + OsInfo $osInfo ) { $this->filesystem = $filesystem; $this->directoryList = $directoryList; $this->driverFile = $driverFile; + $this->osInfo = $osInfo; } /** @@ -224,10 +233,7 @@ public function checkDirectoryPermissionForCLIUser() array_unshift($dirs, $varGenerationDir); foreach ($dirs as $dir) { - if (!is_dir($dir) - || !is_readable($dir) - || !is_executable($dir) - ) { + if (!$this->directoryPermissionForCLIUserValid($dir)) { return false; } } @@ -293,4 +299,15 @@ public function getUnnecessaryWritableDirectoriesForApplication() $current = $this->getApplicationCurrentNonWritableDirectories(); return array_diff($required, $current); } + + /** + * Checks if directory has permissions needed for CLI user (valid directory, readable, and executable.) + * Ignores executable permission for Windows. + * + * @param $dir + * @return bool + */ + private function directoryPermissionForCLIUserValid($dir) { + return (is_dir($dir) && is_readable($dir) && (is_executable($dir) || $this->osInfo->isWindows())); + } } diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php index 29869b89be72a..a1395643a7b15 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php @@ -8,7 +8,6 @@ use \Magento\Framework\Setup\FilePermissions; use Magento\Framework\App\Filesystem\DirectoryList; -use Magento\Framework\Filesystem\Driver\File; class FilePermissionsTest extends \PHPUnit_Framework_TestCase { @@ -32,6 +31,11 @@ class FilePermissionsTest extends \PHPUnit_Framework_TestCase */ private $driverFileMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\OsInfo + */ + private $osInfoMock; + /** * @var FilePermissions */ @@ -42,6 +46,7 @@ public function setUp() $this->directoryWriteMock = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); $this->filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); $this->driverFileMock = $this->getMock('Magento\Framework\Filesystem\Driver\File', [], [], '', false); + $this->osInfoMock = $this->getMock('Magento\Framework\OsInfo', [], [], '', false); $this->filesystemMock ->expects($this->any()) @@ -52,7 +57,8 @@ public function setUp() $this->filePermissions = new FilePermissions( $this->filesystemMock, $this->directoryListMock, - $this->driverFileMock + $this->driverFileMock, + $this->osInfoMock ); } @@ -206,6 +212,46 @@ public function getUnnecessaryWritableDirectoriesForApplicationDataProvider() ]; } + + public function testCheckDirectoryPermissionForCLIUser() + { + $this->directoryListMock->expects($this->once())->method('getPath')->willReturn('/var/generation'); + $this->driverFileMock->expects($this->once()) + ->method('readDirectory') + ->willReturn(['/var/generation/Composer', '/var/gen/Magento']); + // Should never check for OS if executable + $this->osInfoMock->expects($this->never())->method('isWindows'); + $this->assertTrue($this->filePermissions->checkDirectoryPermissionForCLIUser()); + } + + public function testCheckDirectoryPermissionForCLIUserWin() + { + $this->directoryListMock->expects($this->once())->method('getPath')->willReturn('/var/generation'); + $this->driverFileMock->expects($this->once()) + ->method('readDirectory') + ->willReturn(['/var/generation/ComposerNotExec', '/var/gen/Magento']); + // Contains a 'NotExec', so is_executable will return false, isWindows should be called and return true + $this->osInfoMock->expects($this->once())->method('isWindows')->willReturn(true); + $this->assertTrue($this->filePermissions->checkDirectoryPermissionForCLIUser()); + } + + public function testCheckDirectoryPermissionForCLIUserNotExecutable() + { + $this->directoryListMock->expects($this->once())->method('getPath')->willReturn('/var/generation'); + $this->driverFileMock->expects($this->once()) + ->method('readDirectory') + ->willReturn(['/var/generation/ComposerNotExec', '/var/gen/Magento']); + // Contains a 'NotExec', so is_executable will return false, isWindows should be called and return false + $this->osInfoMock->expects($this->once())->method('isWindows')->willReturn(false); + $this->assertFalse($this->filePermissions->checkDirectoryPermissionForCLIUser()); + } + + /* + * exec directory, unix + * non-exec directory, windows + * non-exec directory, unix + */ + public function setUpDirectoryListInstallation() { $this->directoryListMock @@ -285,3 +331,45 @@ public function setUpDirectoryWriteInstallation() ->will($this->returnValue(false)); } } + +namespace Magento\Framework\Setup; + +/** + * Overriding the built-in PHP function is_dir, always returns true,allows unit test of this code without having to setup special directories. + * + * + * @param string $filename + * @return true + */ +function is_dir($filename) +{ + return true; +} + +/** + * Overriding the built-in PHP function is_readable, always returns true, + * allows unit test of this code without having to setup special directories. + * + * @param string $filename + * @return true + */ +function is_readable($filename) +{ + return true; +} + +/** + * Overriding the built-in PHP function is_executable, will return false if directory name contains 'NotExec' + * + * Allows unit test of this code without having to setup a special directory with non-executable permission. + * + * @param string $filename + * @return bool + */ +function is_executable($filename) +{ + if (strpos($filename, 'NotExec') !== false) { + return false; + } + return true; +} From e68f649c883c595fe8bf8a02b01fd78986fb479d Mon Sep 17 00:00:00 2001 From: Paul Lewis Date: Mon, 21 Mar 2016 14:51:22 -0500 Subject: [PATCH 06/17] MAGETWO-50696: Cannot install Magento and run integration tests on Windows - Fix formatting various places --- .../Framework/Setup/FilePermissions.php | 5 ++-- .../Setup/Test/Unit/FilePermissionsTest.php | 24 ++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/internal/Magento/Framework/Setup/FilePermissions.php b/lib/internal/Magento/Framework/Setup/FilePermissions.php index a315fd3013d60..7680912d6a40c 100644 --- a/lib/internal/Magento/Framework/Setup/FilePermissions.php +++ b/lib/internal/Magento/Framework/Setup/FilePermissions.php @@ -304,10 +304,11 @@ public function getUnnecessaryWritableDirectoriesForApplication() * Checks if directory has permissions needed for CLI user (valid directory, readable, and executable.) * Ignores executable permission for Windows. * - * @param $dir + * @param string $dir * @return bool */ - private function directoryPermissionForCLIUserValid($dir) { + private function directoryPermissionForCLIUserValid($dir) + { return (is_dir($dir) && is_readable($dir) && (is_executable($dir) || $this->osInfo->isWindows())); } } diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php index a1395643a7b15..8d27de8f77b10 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php @@ -212,7 +212,9 @@ public function getUnnecessaryWritableDirectoriesForApplicationDataProvider() ]; } - + /** + * Directories have executable permission, not Windows + */ public function testCheckDirectoryPermissionForCLIUser() { $this->directoryListMock->expects($this->once())->method('getPath')->willReturn('/var/generation'); @@ -224,17 +226,24 @@ public function testCheckDirectoryPermissionForCLIUser() $this->assertTrue($this->filePermissions->checkDirectoryPermissionForCLIUser()); } + /** + * Directories do not have executable permissions, is Windows + */ public function testCheckDirectoryPermissionForCLIUserWin() { - $this->directoryListMock->expects($this->once())->method('getPath')->willReturn('/var/generation'); + $this->directoryListMock->expects($this->once())->method('getPath')->willReturn('/var/generationNotExec'); $this->driverFileMock->expects($this->once()) ->method('readDirectory') - ->willReturn(['/var/generation/ComposerNotExec', '/var/gen/Magento']); - // Contains a 'NotExec', so is_executable will return false, isWindows should be called and return true - $this->osInfoMock->expects($this->once())->method('isWindows')->willReturn(true); + ->willReturn(['/var/generation/ComposerNotExec', '/var/generation/MagentoNotExec']); + // Contains a 'NotExec', so is_executable will return false, isWindows should be called once for each + // directory (including parent) and return true + $this->osInfoMock->expects($this->exactly(3))->method('isWindows')->willReturn(true); $this->assertTrue($this->filePermissions->checkDirectoryPermissionForCLIUser()); } + /** + * One directory does not have executable permission, is not Windows + */ public function testCheckDirectoryPermissionForCLIUserNotExecutable() { $this->directoryListMock->expects($this->once())->method('getPath')->willReturn('/var/generation'); @@ -335,8 +344,8 @@ public function setUpDirectoryWriteInstallation() namespace Magento\Framework\Setup; /** - * Overriding the built-in PHP function is_dir, always returns true,allows unit test of this code without having to setup special directories. - * + * Overriding the built-in PHP function is_dir, always returns true, + * allows unit test of this code without having to setup special directories. * * @param string $filename * @return true @@ -360,7 +369,6 @@ function is_readable($filename) /** * Overriding the built-in PHP function is_executable, will return false if directory name contains 'NotExec' - * * Allows unit test of this code without having to setup a special directory with non-executable permission. * * @param string $filename From eb529df3490cd5e41971bc8d5f8fdce2504a4ce4 Mon Sep 17 00:00:00 2001 From: Paul Lewis Date: Mon, 21 Mar 2016 15:14:08 -0500 Subject: [PATCH 07/17] MAGETWO-50696: Cannot install Magento and run integration tests on Windows - Add suppression of unused formal param --- .../Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php index 8d27de8f77b10..3788a1ede33cf 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php @@ -349,6 +349,7 @@ public function setUpDirectoryWriteInstallation() * * @param string $filename * @return true + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ function is_dir($filename) { @@ -361,6 +362,7 @@ function is_dir($filename) * * @param string $filename * @return true + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ function is_readable($filename) { From da567e43e580c5f1f9fed99d582145b5d951d9cf Mon Sep 17 00:00:00 2001 From: Ivan Gavryshko Date: Tue, 29 Mar 2016 08:23:52 -0500 Subject: [PATCH 08/17] MAGETWO-51033: bin/magento commands (setup:cron:run, setup:upgrade, setup:uninstall) should skip session folder - fixed --- .../Filesystem/Filter/ExcludeFilter.php | 56 +++++++++++++++++++ .../Framework/Setup/FilePermissions.php | 11 +++- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 lib/internal/Magento/Framework/Filesystem/Filter/ExcludeFilter.php diff --git a/lib/internal/Magento/Framework/Filesystem/Filter/ExcludeFilter.php b/lib/internal/Magento/Framework/Filesystem/Filter/ExcludeFilter.php new file mode 100644 index 0000000000000..a00bf449718ab --- /dev/null +++ b/lib/internal/Magento/Framework/Filesystem/Filter/ExcludeFilter.php @@ -0,0 +1,56 @@ +_filters = $filters; + } + + /** + * Check whether the current element of the iterator is acceptable + * + * @return bool + */ + public function accept() + { + $current = str_replace('\\', '/', $this->current()->__toString()); + $currentFilename = str_replace('\\', '/', $this->current()->getFilename()); + + if ($currentFilename == '.' || $currentFilename == '..') { + return false; + } + + foreach ($this->_filters as $filter) { + $filter = str_replace('\\', '/', $filter); + if (false !== strpos($current, $filter)) { + return false; + } + } + + return true; + } +} diff --git a/lib/internal/Magento/Framework/Setup/FilePermissions.php b/lib/internal/Magento/Framework/Setup/FilePermissions.php index e70e583c27114..1fb1134de785a 100644 --- a/lib/internal/Magento/Framework/Setup/FilePermissions.php +++ b/lib/internal/Magento/Framework/Setup/FilePermissions.php @@ -8,6 +8,7 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Backup\Filesystem\Iterator\Filter; +use Magento\Framework\Filesystem\Filter\ExcludeFilter; use Magento\Framework\Filesystem; use Magento\Framework\Filesystem\Driver\File; @@ -152,10 +153,18 @@ private function checkRecursiveDirectories($directory) ); $noWritableFilesFolders = [ $this->directoryList->getPath(DirectoryList::GENERATION) . '/', - $this->directoryList->getPath(DirectoryList::DI) .'/' + $this->directoryList->getPath(DirectoryList::DI) . '/', ]; $directoryIterator = new Filter($directoryIterator, $noWritableFilesFolders); + + $directoryIterator = new ExcludeFilter( + $directoryIterator, + [ + $this->directoryList->getPath(DirectoryList::SESSION) . '/', + ] + ); + $foundNonWritable = false; try { From 244bd302bc65c67dcd88407c44756d0ad81b87f8 Mon Sep 17 00:00:00 2001 From: Ankur Kaneria Date: Tue, 29 Mar 2016 12:38:44 -0500 Subject: [PATCH 09/17] MAGETWO-50554: Processing your request errors appears while using Advanced Search with configured Elastic Search - Code review updates --- lib/internal/Magento/Framework/Search/Search.php | 2 +- .../Framework/Search/Test/Unit/SearchTest.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/Search/Search.php b/lib/internal/Magento/Framework/Search/Search.php index 4f4a07e394b69..111bbbebbd8fc 100644 --- a/lib/internal/Magento/Framework/Search/Search.php +++ b/lib/internal/Magento/Framework/Search/Search.php @@ -57,7 +57,7 @@ public function search(SearchCriteriaInterface $searchCriteria) { $this->requestBuilder->setRequestName($searchCriteria->getRequestName()); - $scope = $this->scopeResolver->getScope(); + $scope = $this->scopeResolver->getScope()->getId(); $this->requestBuilder->bindDimension('scope', $scope); foreach ($searchCriteria->getFilterGroups() as $filterGroup) { diff --git a/lib/internal/Magento/Framework/Search/Test/Unit/SearchTest.php b/lib/internal/Magento/Framework/Search/Test/Unit/SearchTest.php index a79b5512c0ec6..cd5efe1ce72e3 100644 --- a/lib/internal/Magento/Framework/Search/Test/Unit/SearchTest.php +++ b/lib/internal/Magento/Framework/Search/Test/Unit/SearchTest.php @@ -65,10 +65,14 @@ protected function setUp() public function testSearch() { $requestName = 'requestName'; - $scope = 333; + $scopeId = 333; $filterField = 'filterField'; $filterValue = 'filterValue'; + $scope = $this->getMockBuilder('Magento\Framework\App\ScopeInterface') + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $filter = $this->getMockBuilder('Magento\Framework\Api\Filter') ->disableOriginalConstructor() ->getMock(); @@ -113,7 +117,7 @@ public function testSearch() ->with($requestName); $this->requestBuilder->expects($this->once()) ->method('bindDimension') - ->with('scope', $scope); + ->with('scope', $scopeId); $this->requestBuilder->expects($this->any()) ->method('bind'); $this->requestBuilder->expects($this->once()) @@ -134,6 +138,10 @@ public function testSearch() ->method('getScope') ->willReturn($scope); + $scope->expects($this->once()) + ->method('getId') + ->willReturn($scopeId); + $searchResult = $this->model->search($searchCriteria); $this->assertInstanceOf('Magento\Framework\Api\Search\SearchResultInterface', $searchResult); From 1740a5dc8dea43f26b5e5e7603233ee62cb34146 Mon Sep 17 00:00:00 2001 From: Ankur Kaneria Date: Tue, 29 Mar 2016 15:52:12 -0500 Subject: [PATCH 10/17] MAGETWO-50554: Processing your request errors appears while using Advanced Search with configured Elastic Search - Code review comment updates --- .../Adapter/Mysql/Aggregation/DataProvider.php | 2 +- .../Plugin/Aggregation/Category/DataProvider.php | 3 +-- .../CatalogSearch/Model/Search/IndexBuilder.php | 13 +++++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php index 7824202ffb31c..ae45233571708 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php @@ -73,7 +73,7 @@ public function getDataSet( array $dimensions, Table $entityIdsTable ) { - $currentScope = $dimensions['scope']->getValue(); + $currentScope = $this->scopeResolver->getScope($dimensions['scope']->getValue())->getId(); $attribute = $this->eavConfig->getAttribute(Product::ENTITY, $bucket->getField()); diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php index da07e516427d1..baed5e22cc00f 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php @@ -67,8 +67,7 @@ public function aroundGetDataSet( Table $entityIdsTable ) { if ($bucket->getField() == 'category_ids') { - $currentScope = $dimensions['scope']->getValue(); - $currentScopeId = $this->scopeResolver->getScope($currentScope)->getId(); + $currentScopeId = $this->scopeResolver->getScope($dimensions['scope']->getValue())->getId(); $currentCategory = $this->layer->getCurrentCategory(); $derivedTable = $this->resource->getConnection()->select(); diff --git a/app/code/Magento/CatalogSearch/Model/Search/IndexBuilder.php b/app/code/Magento/CatalogSearch/Model/Search/IndexBuilder.php index 05535aaebd204..a6510bb33fb1c 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/IndexBuilder.php +++ b/app/code/Magento/CatalogSearch/Model/Search/IndexBuilder.php @@ -20,6 +20,7 @@ use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver; use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\App\ScopeResolverInterface; /** * Build base Query for Index @@ -57,6 +58,11 @@ class IndexBuilder implements IndexBuilderInterface */ private $tableMapper; + /** + * @var ScopeResolverInterface + */ + private $dimensionScopeResolver; + /** * @param \Magento\Framework\App\ResourceConnection $resource * @param ScopeConfigInterface $config @@ -64,6 +70,7 @@ class IndexBuilder implements IndexBuilderInterface * @param ConditionManager $conditionManager * @param IndexScopeResolver $scopeResolver * @param TableMapper $tableMapper + * @param ScopeResolverInterface $dimensionScopeResolver */ public function __construct( ResourceConnection $resource, @@ -71,7 +78,8 @@ public function __construct( StoreManagerInterface $storeManager, ConditionManager $conditionManager, IndexScopeResolver $scopeResolver, - TableMapper $tableMapper + TableMapper $tableMapper, + ScopeResolverInterface $dimensionScopeResolver ) { $this->resource = $resource; $this->config = $config; @@ -79,6 +87,7 @@ public function __construct( $this->conditionManager = $conditionManager; $this->scopeResolver = $scopeResolver; $this->tableMapper = $tableMapper; + $this->dimensionScopeResolver = $dimensionScopeResolver; } /** @@ -158,7 +167,7 @@ private function prepareDimensions(array $dimensions) $preparedDimensions[] = $this->conditionManager->generateCondition( $dimension->getName(), '=', - $dimension->getValue() + $this->dimensionScopeResolver->getScope($dimension->getValue())->getId() ); } From 7ee01a70c5b9b7df3a8c775457b2918ee5288dc4 Mon Sep 17 00:00:00 2001 From: Eddie Lau Date: Tue, 29 Mar 2016 16:59:51 -0500 Subject: [PATCH 11/17] MAGETWO-51327: composer.json should not be required to run bin/magento CLI - delayed creation of dependency graph in DependencyChecker --- lib/internal/Magento/Framework/Module/DependencyChecker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Module/DependencyChecker.php b/lib/internal/Magento/Framework/Module/DependencyChecker.php index 1149d2f35bcdb..92adbd6fbb7bf 100644 --- a/lib/internal/Magento/Framework/Module/DependencyChecker.php +++ b/lib/internal/Magento/Framework/Module/DependencyChecker.php @@ -50,7 +50,6 @@ public function __construct(ModuleList $list, ModuleList\Loader $loader, Package $this->enabledModuleList = $list->getNames(); $this->fullModuleList = $loader->load(); $this->packageInfo = $packageInfoFactory->create(); - $this->graph = $this->createGraph(); } /** @@ -93,6 +92,7 @@ public function checkDependenciesWhenEnableModules($toBeEnabledModules, $current */ private function checkDependencyGraph($isEnable, $moduleNames, $enabledModules) { + $this->graph = $this->createGraph(); $dependenciesMissingAll = []; $graphMode = $isEnable ? Graph::DIRECTIONAL : Graph::INVERSE; foreach ($moduleNames as $moduleName) { From aae8ddb8c380624edafc210aefff82f8aed96ff3 Mon Sep 17 00:00:00 2001 From: Ankur Kaneria Date: Wed, 30 Mar 2016 10:13:39 -0500 Subject: [PATCH 12/17] MAGETWO-50554: Processing your request errors appears while using Advanced Search with configured Elastic Search - Updates to fix failing unit test --- .../Unit/Model/Search/IndexBuilderTest.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php index ab297eeab5d7c..b50f3459d22fe 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php @@ -46,6 +46,16 @@ class IndexBuilderTest extends \PHPUnit_Framework_TestCase */ private $target; + /** + * @var \Magento\Framework\App\ScopeResolverInterface|\MockObject + */ + private $dimensionScopeResolver; + + /** + * @var \Magento\Framework\App\ScopeInterface|\MockObject + */ + private $scopeInterface; + protected function setUp() { $this->select = $this->getMockBuilder('\Magento\Framework\DB\Select') @@ -118,6 +128,16 @@ function ($left, $operator, $right) { ->method('addTables') ->with($this->select, $this->request) ->willReturnArgument(0); + $this->dimensionScopeResolver = $this->getMockForAbstractClass( + '\Magento\Framework\App\ScopeResolverInterface', + [], + '', + false); + $this->scopeInterface = $this->getMockForAbstractClass( + '\Magento\Framework\App\ScopeInterface', + [], + '', + false); $objectManagerHelper = new ObjectManagerHelper($this); $this->target = $objectManagerHelper->getObject( @@ -129,6 +149,7 @@ function ($left, $operator, $right) { 'conditionManager' => $this->conditionManager, 'scopeResolver' => $this->scopeResolver, 'tableMapper' => $this->tableMapper, + 'dimensionScopeResolver' => $this->dimensionScopeResolver ] ); } @@ -167,6 +188,12 @@ public function testBuildWithoutOutOfStock() $this->request->expects($this->exactly(2)) ->method('getDimensions') ->willReturn($dimensions); + $this->dimensionScopeResolver->expects($this->once()) + ->method('getScope') + ->willReturn($this->scopeInterface); + $this->scopeInterface->expects($this->once()) + ->method('getId') + ->willReturn('someValue'); $this->mockBuild($index, $tableSuffix, false); From 625d3ee5dcb7907bc7b0b435aa41150065883a81 Mon Sep 17 00:00:00 2001 From: Ankur Kaneria Date: Wed, 30 Mar 2016 10:49:28 -0500 Subject: [PATCH 13/17] MAGETWO-50554: Processing your request errors appears while using Advanced Search with configured Elastic Search - Update to reduce coupling between objects --- .../Unit/Model/Search/IndexBuilderTest.php | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php index b50f3459d22fe..69244ee47119d 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php @@ -6,39 +6,36 @@ namespace Magento\CatalogSearch\Test\Unit\Model\Search; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -use PHPUnit_Framework_MockObject_MockObject as MockObject; - /** * Test for \Magento\CatalogSearch\Model\Search\IndexBuilder */ class IndexBuilderTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\CatalogSearch\Model\Search\TableMapper|MockObject */ + /** @var \Magento\CatalogSearch\Model\Search\TableMapper|\PHPUnit_Framework_MockObject_MockObject */ private $tableMapper; - /** @var \Magento\Framework\Search\Adapter\Mysql\ConditionManager|MockObject */ + /** @var \Magento\Framework\Search\Adapter\Mysql\ConditionManager|\PHPUnit_Framework_MockObject_MockObject */ private $conditionManager; - /** @var \Magento\Search\Model\IndexScopeResolver|MockObject */ + /** @var \Magento\Search\Model\IndexScopeResolver|\PHPUnit_Framework_MockObject_MockObject */ private $scopeResolver; - /** @var \Magento\Framework\DB\Adapter\AdapterInterface|MockObject */ + /** @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject */ private $connection; - /** @var \Magento\Framework\DB\Select|MockObject */ + /** @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject */ private $select; - /** @var \Magento\Framework\App\Config\ScopeConfigInterface|MockObject */ + /** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ private $config; - /** @var \Magento\Store\Model\StoreManagerInterface|MockObject */ + /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ private $storeManager; - /** @var \Magento\Framework\Search\RequestInterface|MockObject */ + /** @var \Magento\Framework\Search\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ private $request; - /** @var \Magento\Search\Model\IndexScopeResolver|MockObject */ + /** @var \Magento\Search\Model\IndexScopeResolver|\PHPUnit_Framework_MockObject_MockObject */ private $resource; /** @@ -47,12 +44,12 @@ class IndexBuilderTest extends \PHPUnit_Framework_TestCase private $target; /** - * @var \Magento\Framework\App\ScopeResolverInterface|\MockObject + * @var \Magento\Framework\App\ScopeResolverInterface|\PHPUnit_Framework_MockObject_MockObject */ private $dimensionScopeResolver; /** - * @var \Magento\Framework\App\ScopeInterface|\MockObject + * @var \Magento\Framework\App\ScopeInterface|\PHPUnit_Framework_MockObject_MockObject */ private $scopeInterface; @@ -132,14 +129,16 @@ function ($left, $operator, $right) { '\Magento\Framework\App\ScopeResolverInterface', [], '', - false); + false + ); $this->scopeInterface = $this->getMockForAbstractClass( '\Magento\Framework\App\ScopeInterface', [], '', - false); + false + ); - $objectManagerHelper = new ObjectManagerHelper($this); + $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->target = $objectManagerHelper->getObject( 'Magento\CatalogSearch\Model\Search\IndexBuilder', [ From 5f38c807d559377cbc06bfe10e7a448f017a5ae3 Mon Sep 17 00:00:00 2001 From: Ankur Kaneria Date: Wed, 30 Mar 2016 11:47:09 -0500 Subject: [PATCH 14/17] MAGETWO-50554: Processing your request errors appears while using Advanced Search with configured Elastic Search - Minor update to fix static test issue --- .../CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php index 69244ee47119d..626475c1f3276 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php @@ -8,6 +8,8 @@ /** * Test for \Magento\CatalogSearch\Model\Search\IndexBuilder + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class IndexBuilderTest extends \PHPUnit_Framework_TestCase { @@ -296,7 +298,7 @@ function ($index, $dimensions) { /** * @param $name * @param $value - * @return MockObject + * @return PHPUnit_Framework_MockObject_MockObject */ private function createDimension($name, $value) { From 71cfcfe82b7b5fb2adbb85938e7414bfab1fc950 Mon Sep 17 00:00:00 2001 From: Ankur Kaneria Date: Wed, 30 Mar 2016 12:30:52 -0500 Subject: [PATCH 15/17] MAGETWO-50554: Processing your request errors appears while using Advanced Search with configured Elastic Search - minor update for static test --- .../CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php index 626475c1f3276..fbc2a9c3b2463 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php @@ -298,7 +298,7 @@ function ($index, $dimensions) { /** * @param $name * @param $value - * @return PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit_Framework_MockObject_MockObject */ private function createDimension($name, $value) { From 2967e8a574f0698fb5d34e3c2544ae3f03928360 Mon Sep 17 00:00:00 2001 From: Ivan Gavryshko Date: Wed, 30 Mar 2016 13:46:52 -0500 Subject: [PATCH 16/17] MAGETWO-51033: bin/magento commands (setup:cron:run, setup:upgrade, setup:uninstall) should skip session folder - added test --- .../Test/Unit/File/ExcludeFilterTest.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ExcludeFilterTest.php diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ExcludeFilterTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ExcludeFilterTest.php new file mode 100644 index 0000000000000..bca9b5b667685 --- /dev/null +++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/File/ExcludeFilterTest.php @@ -0,0 +1,57 @@ +iterator = $this->getFilesIterator(); + } + + public function testExclusion() + { + $iterator = new ExcludeFilter( + $this->iterator, + [ + BP . '/var/session/' + ] + ); + + foreach ($iterator as $i) { + $result[] = $i; + } + + $this->assertTrue(!in_array(BP . '/var/session/', $result), 'Filtered path should not be in array'); + } + + private function getFilesIterator () + { + $files = [ + BP . '/var/', + BP . '/var/session/', + BP . '/var/cache/' + ]; + + foreach ($files as $file) { + $item = $this->getMockBuilder('SplFileInfoClass')->setMethods(['__toString', 'getFilename'])->getMock(); + $item->expects($this->any())->method('__toString')->willReturn($file); + $item->expects($this->any())->method('getFilename')->willReturn('notDots'); + yield $item; + } + } +} From c18a07eb5c2538520cb433d521c58902d42b5f5e Mon Sep 17 00:00:00 2001 From: Maddy Chellathurai Date: Wed, 30 Mar 2016 15:24:27 -0500 Subject: [PATCH 17/17] MAGETWO-51371: Wrong message in CLI output for installation - changing way string append is done. --- setup/src/Magento/Setup/Model/Installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php index 43a2c3a836294..3cce200fbe20e 100644 --- a/setup/src/Magento/Setup/Model/Installer.php +++ b/setup/src/Magento/Setup/Model/Installer.php @@ -824,7 +824,7 @@ private function handleDBSchemaData($setup, $type) $this->log->log("Module '{$moduleName}':"); $modulePostUpdater = $this->getSchemaDataHandler($moduleName, $handlerType); if ($modulePostUpdater) { - $this->log->logInline('Running ' + str_replace('-', ' ', $handlerType) + '...'); + $this->log->logInline('Running ' . str_replace('-', ' ', $handlerType) . '...'); $modulePostUpdater->install($setup, $moduleContextList[$moduleName]); } $this->logProgress();