From 7c534a2407569a8affd05bcf83987b171962ed38 Mon Sep 17 00:00:00 2001 From: Alex Gusev Date: Wed, 15 Jun 2016 17:22:43 +0300 Subject: [PATCH 01/65] Change 'select' to 'query' in props See https://github.com/magento/magento2/issues/5040 --- .../Magento/Framework/Data/AbstractSearchResult.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/Data/AbstractSearchResult.php b/lib/internal/Magento/Framework/Data/AbstractSearchResult.php index b2abd7ab66827..5125aac3331d5 100644 --- a/lib/internal/Magento/Framework/Data/AbstractSearchResult.php +++ b/lib/internal/Magento/Framework/Data/AbstractSearchResult.php @@ -59,9 +59,9 @@ abstract class AbstractSearchResult extends AbstractDataObject implements Search protected $entityFactory; /** - * @var \Magento\Framework\DB\Select - */ - protected $select; + * @var \Magento\Framework\DB\Query + */ + protected $query; /** * @var \Magento\Framework\Data\SearchResultIteratorFactory From a4d69943356920f93d78101377f2bef1e3d528ec Mon Sep 17 00:00:00 2001 From: Alex Gusev Date: Wed, 15 Jun 2016 17:53:16 +0300 Subject: [PATCH 02/65] Fix Travis CI error 63 | ERROR | Expected 5 space(s) before asterisk; 4 found --- lib/internal/Magento/Framework/Data/AbstractSearchResult.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Data/AbstractSearchResult.php b/lib/internal/Magento/Framework/Data/AbstractSearchResult.php index 5125aac3331d5..a7539d2c37cba 100644 --- a/lib/internal/Magento/Framework/Data/AbstractSearchResult.php +++ b/lib/internal/Magento/Framework/Data/AbstractSearchResult.php @@ -60,7 +60,7 @@ abstract class AbstractSearchResult extends AbstractDataObject implements Search /** * @var \Magento\Framework\DB\Query - */ + */ protected $query; /** From fca2421b737e224f46ae57098094bb99b2508974 Mon Sep 17 00:00:00 2001 From: Alex Gusev Date: Fri, 17 Jun 2016 17:27:03 +0300 Subject: [PATCH 03/65] QueryInterface & old $select - use interface instead of class itself; - leave deprecated $select property; --- .../Magento/Framework/Data/AbstractSearchResult.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Data/AbstractSearchResult.php b/lib/internal/Magento/Framework/Data/AbstractSearchResult.php index a7539d2c37cba..24f93a054957c 100644 --- a/lib/internal/Magento/Framework/Data/AbstractSearchResult.php +++ b/lib/internal/Magento/Framework/Data/AbstractSearchResult.php @@ -59,9 +59,15 @@ abstract class AbstractSearchResult extends AbstractDataObject implements Search protected $entityFactory; /** - * @var \Magento\Framework\DB\Query + * @var \Magento\Framework\DB\QueryInterface */ protected $query; + + /** + * @var \Magento\Framework\DB\Select + * @deprecated + */ + protected $select; /** * @var \Magento\Framework\Data\SearchResultIteratorFactory From ef7d3df82532240202970289697a2b00b784a9d3 Mon Sep 17 00:00:00 2001 From: Erik Hansen Date: Wed, 29 Jun 2016 15:27:15 -0500 Subject: [PATCH 04/65] Change pub/.htaccess developer mode comment --- pub/.htaccess | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pub/.htaccess b/pub/.htaccess index 926c012eef6a5..2b7595e506fd3 100644 --- a/pub/.htaccess +++ b/pub/.htaccess @@ -2,7 +2,8 @@ ## Optional override of deployment mode. We recommend you use the ## command bin/magento deploy:mode:set to switch modes instead -# SetEnv MAGE_MODE default # or production or developer + # Options are default, production, or developer +# SetEnv MAGE_MODE default ############################################ ## Uncomment these lines for CGI mode. From ab2f83ed8d44d7a9e7335c4b06956e68e85eb41b Mon Sep 17 00:00:00 2001 From: alojua Date: Thu, 21 Jul 2016 19:08:34 +0200 Subject: [PATCH 05/65] fix collection walk when using specific callback instead of default model --- lib/internal/Magento/Framework/Data/Collection.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/Data/Collection.php b/lib/internal/Magento/Framework/Data/Collection.php index deda1304047bc..764d445acb553 100644 --- a/lib/internal/Magento/Framework/Data/Collection.php +++ b/lib/internal/Magento/Framework/Data/Collection.php @@ -500,16 +500,19 @@ public function clear() */ public function walk($callback, array $args = []) { - $results = []; + $results = []; $useItemCallback = is_string($callback) && strpos($callback, '::') === false; foreach ($this->getItems() as $id => $item) { + $params = $args; if ($useItemCallback) { $cb = [$item, $callback]; } else { $cb = $callback; - array_unshift($args, $item); + array_unshift($params, $item); } - $results[$id] = call_user_func_array($cb, $args); + //@codingStandardsIgnoreStart + $results[$id] = call_user_func_array($cb, $params); + //@codingStandardsIgnoreEnd } return $results; } From 08047dc91b1f6dbcff68524b34dd57af62397849 Mon Sep 17 00:00:00 2001 From: alojua Date: Thu, 21 Jul 2016 19:12:01 +0200 Subject: [PATCH 06/65] wrong identation --- lib/internal/Magento/Framework/Data/Collection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Data/Collection.php b/lib/internal/Magento/Framework/Data/Collection.php index 764d445acb553..b0ec77bb1fdc9 100644 --- a/lib/internal/Magento/Framework/Data/Collection.php +++ b/lib/internal/Magento/Framework/Data/Collection.php @@ -500,7 +500,7 @@ public function clear() */ public function walk($callback, array $args = []) { - $results = []; + $results = []; $useItemCallback = is_string($callback) && strpos($callback, '::') === false; foreach ($this->getItems() as $id => $item) { $params = $args; From f82e365e82fdaefae192ba3e5a8860f79cec6495 Mon Sep 17 00:00:00 2001 From: Navarr Barnier Date: Mon, 29 Aug 2016 12:40:58 -0400 Subject: [PATCH 07/65] Replace EE License Placeholder text with filename Resolves #5528 --- COPYING.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/COPYING.txt b/COPYING.txt index d7d04f5b7edba..ef4605e3beab4 100644 --- a/COPYING.txt +++ b/COPYING.txt @@ -4,4 +4,4 @@ http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) Please see LICENSE.txt for the full text of the OSL 3.0 license or contact license@magentocommerce.com for a copy. Subject to Licensee's payment of fees and compliance with the terms and conditions of the MEE License, the MEE License supersedes the OSL 3.0 license for each source file. -Please see for the full text of the MEE License or visit http://magento.com/legal/terms/enterprise. \ No newline at end of file +Please see LICENSE_EE.txt for the full text of the MEE License or visit http://magento.com/legal/terms/enterprise. From 384bcc358d773d8a87275e335335f82559237368 Mon Sep 17 00:00:00 2001 From: Navarr Barnier Date: Thu, 1 Sep 2016 08:48:28 -0400 Subject: [PATCH 08/65] Refactor Option ResourceModel to allow price supporting types to be intercepted This commit allows the price and price_type functionality to be expanded by third party modules with no real change in the logic utilized. --- .../Model/ResourceModel/Product/Option.php | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Option.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Option.php index 7b23e5979c8b8..ddf26ff80143f 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Option.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Option.php @@ -105,13 +105,7 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje * If there is not price skip saving price */ - if ($object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_FIELD || - $object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_AREA || - $object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_FILE || - $object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE || - $object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE_TIME || - $object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_TIME - ) { + if (in_array($object->getType(), $this->getPriceTypes())) { //save for store_id = 0 if (!$object->getData('scope', 'price')) { $statement = $connection->select()->from( @@ -559,6 +553,23 @@ public function getSearchableData($productId, $storeId) return $searchData; } + + /** + * All Option Types that support price and price_type + * + * @return string[] + */ + public function getPriceTypes() + { + return [ + \Magento\Catalog\Model\Product\Option::OPTION_TYPE_FIELD, + \Magento\Catalog\Model\Product\Option::OPTION_TYPE_AREA, + \Magento\Catalog\Model\Product\Option::OPTION_TYPE_FILE, + \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE, + \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE_TIME, + \Magento\Catalog\Model\Product\Option::OPTION_TYPE_TIME, + ]; + } /** * @return \Magento\Framework\EntityManager\MetadataPool From 90fb4089ce616e49e9333ff33396bf2e2578be7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Corr=C3=AAa=20Gomes?= Date: Thu, 6 Oct 2016 15:25:03 -0300 Subject: [PATCH 09/65] Good practice, license in readme file It's very interesting for forks too. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5f6b4716af5d1..bfcc1a411909a 100644 --- a/README.md +++ b/README.md @@ -79,3 +79,7 @@ To report security vulnerabilities in Magento software or web sites, please e-ma Stay up-to-date on the latest vulnerabilities and patches for Magento by signing up for Security Alert Notifications. +

License

+ +OSL 3.0 (c) [Magento Inc.](https://github.com/magento/) + From c05293c5895e169843d27423eae626a7b454932e Mon Sep 17 00:00:00 2001 From: dverkade Date: Tue, 27 Sep 2016 16:21:06 +0200 Subject: [PATCH 10/65] Changed constructor to use an interface The front controller only accepts an HTTP response object. The front controller now has a direct dependency on the Response\Http class, which is not correct. The front controller should not care which response object will be injected only that it will adhire the ResponseInterface. So changed this constructor to accept a ResponseInterface which in di.xml is being replaced by the Response\Http class. --- lib/internal/Magento/Framework/App/FrontController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/App/FrontController.php b/lib/internal/Magento/Framework/App/FrontController.php index 81a3e3f84379b..26c9f1948630f 100644 --- a/lib/internal/Magento/Framework/App/FrontController.php +++ b/lib/internal/Magento/Framework/App/FrontController.php @@ -15,17 +15,17 @@ class FrontController implements FrontControllerInterface protected $_routerList; /** - * @var \Magento\Framework\App\Response\Http + * @var \Magento\Framework\App\ResponseInterface */ protected $response; /** * @param RouterList $routerList - * @param \Magento\Framework\App\Response\Http $response + * @param \Magento\Framework\App\ResponseInterface $response */ public function __construct( RouterList $routerList, - \Magento\Framework\App\Response\Http $response + \Magento\Framework\App\ResponseInterface $response ) { $this->_routerList = $routerList; $this->response = $response; From 8bfe7ea5e5d8997e3398a0c03ad877b19c7b19c2 Mon Sep 17 00:00:00 2001 From: Hungvt Date: Thu, 17 Nov 2016 11:47:20 +0700 Subject: [PATCH 11/65] Update IsAllowedGuestCheckoutObserver.php --- .../Downloadable/Observer/IsAllowedGuestCheckoutObserver.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Downloadable/Observer/IsAllowedGuestCheckoutObserver.php b/app/code/Magento/Downloadable/Observer/IsAllowedGuestCheckoutObserver.php index ef727c6ef0e53..c7a7b5496ef99 100644 --- a/app/code/Magento/Downloadable/Observer/IsAllowedGuestCheckoutObserver.php +++ b/app/code/Magento/Downloadable/Observer/IsAllowedGuestCheckoutObserver.php @@ -43,8 +43,6 @@ public function execute(\Magento\Framework\Event\Observer $observer) $store = $observer->getEvent()->getStore(); $result = $observer->getEvent()->getResult(); - $result->setIsAllowed(true); - if (!$this->_scopeConfig->isSetFlag( self::XML_PATH_DISABLE_GUEST_CHECKOUT, ScopeInterface::SCOPE_STORE, From b8123a0e8b37d699f65a264b9e121a216978b014 Mon Sep 17 00:00:00 2001 From: Rafael Kassner Date: Mon, 21 Nov 2016 15:40:35 +0100 Subject: [PATCH 12/65] Add configurations for change email templates --- app/code/Magento/Customer/etc/adminhtml/system.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/code/Magento/Customer/etc/adminhtml/system.xml b/app/code/Magento/Customer/etc/adminhtml/system.xml index f542c2b6e0f5e..c1b846597918c 100644 --- a/app/code/Magento/Customer/etc/adminhtml/system.xml +++ b/app/code/Magento/Customer/etc/adminhtml/system.xml @@ -180,6 +180,19 @@ Magento\Config\Model\Config\Source\Yesno + + + + + Email template chosen based on theme fallback when "Default" option is selected. + Magento\Config\Model\Config\Source\Email\Template + + + + Email template chosen based on theme fallback when "Default" option is selected. + Magento\Config\Model\Config\Source\Email\Template + + From 346df3f18a7040d040141de6b2277f04ac43baf7 Mon Sep 17 00:00:00 2001 From: Eino Keskitalo Date: Wed, 8 Feb 2017 10:36:56 +0200 Subject: [PATCH 13/65] Fix product option files not copying to order dir. Copy product option file to order directory from quote also when media storage is set to file system, not just database. Also rename _rootDirectory variable to _mediaDirectory, since that's what it is. --- .../Model/Product/Option/Type/File.php | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php index 1c1c27baafe2a..e09b24b9ca823 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php @@ -32,9 +32,9 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType protected $_formattedOptionValue = null; /** - * @var \Magento\Framework\Filesystem\Directory\ReadInterface + * @var \Magento\Framework\Filesystem\Directory\Write */ - protected $_rootDirectory; + protected $_mediaDirectory; /** * Core file storage database @@ -114,7 +114,7 @@ public function __construct( $this->_escaper = $escaper; $this->_coreFileStorageDatabase = $coreFileStorageDatabase; $this->filesystem = $filesystem ?: \Magento\Framework\App\ObjectManager::getInstance()->get(Filesystem::class); - $this->_rootDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA); + $this->_mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); $this->validatorInfo = $validatorInfo; $this->validatorFile = $validatorFile; $this->serializer = $serializer ? $serializer : ObjectManager::getInstance()->get(Json::class); @@ -473,13 +473,18 @@ public function copyQuoteToOrder() $quotePath = $value['quote_path']; $orderPath = $value['order_path']; - if (!$this->_rootDirectory->isFile($quotePath) || !$this->_rootDirectory->isReadable($quotePath)) { + if (!$this->_mediaDirectory->isFile($quotePath) || !$this->_mediaDirectory->isReadable($quotePath)) { throw new \Exception(); } - $this->_coreFileStorageDatabase->copyFile( - $this->_rootDirectory->getAbsolutePath($quotePath), - $this->_rootDirectory->getAbsolutePath($orderPath) - ); + + if ($this->_coreFileStorageDatabase->checkDbUsage()) { + $this->_coreFileStorageDatabase->copyFile( + $this->_mediaDirectory->getAbsolutePath($quotePath), + $this->_mediaDirectory->getAbsolutePath($orderPath) + ); + } else { + $this->_mediaDirectory->copyFile($quotePath, $orderPath); + } } catch (\Exception $e) { return $this; } From 3a2a057cf0c10a09d376f63eefd1caacbece05e5 Mon Sep 17 00:00:00 2001 From: Eino Keskitalo Date: Wed, 8 Feb 2017 16:55:31 +0200 Subject: [PATCH 14/65] Fix whitespace --- .../Model/Product/Option/Type/File.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php index e09b24b9ca823..2423a3d7f032d 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php @@ -472,15 +472,7 @@ public function copyQuoteToOrder() } $quotePath = $value['quote_path']; $orderPath = $value['order_path']; - - if (!$this->_mediaDirectory->isFile($quotePath) || !$this->_mediaDirectory->isReadable($quotePath)) { - throw new \Exception(); - } - - if ($this->_coreFileStorageDatabase->checkDbUsage()) { - $this->_coreFileStorageDatabase->copyFile( - $this->_mediaDirectory->getAbsolutePath($quotePath), - $this->_mediaDirectory->getAbsolutePath($orderPath) + $this->_mediaDirectory->getAbsolutePath($orderPath) ); } else { $this->_mediaDirectory->copyFile($quotePath, $orderPath); @@ -497,7 +489,15 @@ public function copyQuoteToOrder() * @param string $url * @return $this */ - public function setCustomOptionDownloadUrl($url) + public function setCustomOp + if (!$this->_mediaDirectory->isFile($quotePath) || !$this->_mediaDirectory->isReadable($quotePath)) { + throw new \Exception(); + } + + if ($this->_coreFileStorageDatabase->checkDbUsage()) { + $this->_coreFileStorageDatabase->copyFile( + $this->_mediaDirectory->getAbsolutePath($quotePath), + tionDownloadUrl($url) { $this->_customOptionDownloadUrl = $url; return $this; From 84ca28b1f28cea4ca26524cdfba7383df6607eaf Mon Sep 17 00:00:00 2001 From: alojua Date: Fri, 24 Feb 2017 16:29:47 +0100 Subject: [PATCH 15/65] remove not needed code standards ignore --- lib/internal/Magento/Framework/Data/Collection.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Data/Collection.php b/lib/internal/Magento/Framework/Data/Collection.php index 488942041d8bb..5938fa8afa7cb 100644 --- a/lib/internal/Magento/Framework/Data/Collection.php +++ b/lib/internal/Magento/Framework/Data/Collection.php @@ -510,9 +510,7 @@ public function walk($callback, array $args = []) $cb = $callback; array_unshift($params, $item); } - //@codingStandardsIgnoreStart $results[$id] = call_user_func_array($cb, $params); - //@codingStandardsIgnoreEnd } return $results; } From c4ac9ef03baddd20c0df60fe51b6e942afe85880 Mon Sep 17 00:00:00 2001 From: Eino Keskitalo Date: Fri, 3 Mar 2017 10:56:09 +0200 Subject: [PATCH 16/65] Revert "Fix whitespace" This reverts commit 3a2a057cf0c10a09d376f63eefd1caacbece05e5. This was a very broken commit. --- .../Model/Product/Option/Type/File.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php index 2423a3d7f032d..e09b24b9ca823 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php @@ -472,7 +472,15 @@ public function copyQuoteToOrder() } $quotePath = $value['quote_path']; $orderPath = $value['order_path']; - $this->_mediaDirectory->getAbsolutePath($orderPath) + + if (!$this->_mediaDirectory->isFile($quotePath) || !$this->_mediaDirectory->isReadable($quotePath)) { + throw new \Exception(); + } + + if ($this->_coreFileStorageDatabase->checkDbUsage()) { + $this->_coreFileStorageDatabase->copyFile( + $this->_mediaDirectory->getAbsolutePath($quotePath), + $this->_mediaDirectory->getAbsolutePath($orderPath) ); } else { $this->_mediaDirectory->copyFile($quotePath, $orderPath); @@ -489,15 +497,7 @@ public function copyQuoteToOrder() * @param string $url * @return $this */ - public function setCustomOp - if (!$this->_mediaDirectory->isFile($quotePath) || !$this->_mediaDirectory->isReadable($quotePath)) { - throw new \Exception(); - } - - if ($this->_coreFileStorageDatabase->checkDbUsage()) { - $this->_coreFileStorageDatabase->copyFile( - $this->_mediaDirectory->getAbsolutePath($quotePath), - tionDownloadUrl($url) + public function setCustomOptionDownloadUrl($url) { $this->_customOptionDownloadUrl = $url; return $this; From 00dd57db463ea8c3135c38c1957ae3d2525d6140 Mon Sep 17 00:00:00 2001 From: Eino Keskitalo Date: Fri, 3 Mar 2017 13:12:26 +0200 Subject: [PATCH 17/65] Update product file option test to match File class better. It should still test mediaDirectory->copyFile(). --- .../Model/Product/Option/Type/FileTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php index e1ea4b3b5453d..668efce48eb27 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php @@ -8,7 +8,7 @@ use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Filesystem; -use Magento\Framework\Filesystem\Directory\ReadInterface; +use Magento\Framework\Filesystem\Directory\WriteInterface; use Magento\Framework\Filesystem\DriverPool; /** @@ -24,9 +24,9 @@ class FileTest extends \PHPUnit_Framework_TestCase protected $objectManager; /** - * @var ReadInterface|\PHPUnit_Framework_MockObject_MockObject + * @var WriteInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $rootDirectory; + protected $mediaDirectory; /** * @var \Magento\MediaStorage\Helper\File\Storage\Database|\PHPUnit_Framework_MockObject_MockObject @@ -61,13 +61,13 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->rootDirectory = $this->getMockBuilder(ReadInterface::class) + $this->mediaDirectory = $this->getMockBuilder(WriteInterface::class) ->getMock(); $this->filesystemMock->expects($this->any()) - ->method('getDirectoryRead') + ->method('getDirectoryWrite') ->with(DirectoryList::MEDIA, DriverPool::FILE) - ->willReturn($this->rootDirectory); + ->willReturn($this->mediaDirectory); $this->serializer = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class) ->disableOriginalConstructor() @@ -158,17 +158,17 @@ function ($value) { ->method('getValue') ->will($this->returnValue($quoteValue)); - $this->rootDirectory->expects($this->any()) + $this->mediaDirectory->expects($this->any()) ->method('isFile') ->with($this->equalTo($quotePath)) ->will($this->returnValue(true)); - $this->rootDirectory->expects($this->any()) + $this->mediaDirectory->expects($this->any()) ->method('isReadable') ->with($this->equalTo($quotePath)) ->will($this->returnValue(true)); - $this->rootDirectory->expects($this->any()) + $this->mediaDirectory->expects($this->any()) ->method('getAbsolutePath') ->will($this->returnValue('/file.path')); From 27405be680c77857e3d4ba28fc8682c4bdb4f22a Mon Sep 17 00:00:00 2001 From: Hans Schouten Date: Wed, 8 Mar 2017 19:59:08 +0100 Subject: [PATCH 18/65] Modified css transitions --- lib/web/css/source/components/_modals.less | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/web/css/source/components/_modals.less b/lib/web/css/source/components/_modals.less index 70048e001ad3a..7769423696b2e 100644 --- a/lib/web/css/source/components/_modals.less +++ b/lib/web/css/source/components/_modals.less @@ -48,9 +48,15 @@ right: 0; top: 0; visibility: hidden; + opacity: 0; + -webkit-transition: visibility 0s .3s, opacity .3s ease; + transition: visibility 0s .3s, opacity .3s ease; &._show { visibility: visible; + opacity: 1; + -webkit-transition: opacity .3s ease; + transition: opacity .3s ease; .modal-inner-wrap { -webkit-transform: translate(0, 0); @@ -83,10 +89,8 @@ position: static; -webkit-transform: translateX(100%); transform: translateX(100%); - transition-duration: .3s; - -webkit-transition-property: -webkit-transform, visibility; - transition-property: transform, visibility; - transition-timing-function: ease-in-out; + -webkit-transition: -webkit-transform .3s ease-in-out; + transition: transform .3s ease-in-out; width: auto; } } @@ -115,10 +119,8 @@ right: 0; -webkit-transform: translateY(-200%); transform: translateY(-200%); - transition-duration: .2s; - -webkit-transition-property: -webkit-transform, visibility; - transition-property: transform, visibility; - transition-timing-function: ease; + -webkit-transition: -webkit-transform .2s ease; + transition: transform .2s ease; } } From 45546a7305343eba5a29e1a086d4f8613cd8e576 Mon Sep 17 00:00:00 2001 From: Bartek Igielski Date: Thu, 30 Mar 2017 10:53:14 +0200 Subject: [PATCH 19/65] Upgrade dependecies and change versioning rules. --- package.json.sample | 62 +++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/package.json.sample b/package.json.sample index d73606809abe6..2b657ac172b93 100644 --- a/package.json.sample +++ b/package.json.sample @@ -1,8 +1,7 @@ { - "name": "Magento2", + "name": "magento2", "author": "Magento Commerce Inc.", "description": "Magento2 node modules dependencies for local development", - "version": "2.0.0", "license": "(OSL-3.0 OR AFL-3.0)", "repository": { "type": "git", @@ -10,36 +9,33 @@ }, "homepage": "http://magento.com/", "devDependencies": { - "glob": "^5.0.14", - "grunt": "^0.4.5", - "grunt-autoprefixer": "^2.0.0", - "grunt-banner": "^0.4.0", - "grunt-contrib-clean": "^0.6.0", - "grunt-contrib-connect": "^0.9.0", - "grunt-contrib-cssmin": "^0.10.0", - "grunt-contrib-imagemin": "^0.9.2", - "grunt-contrib-jasmine": "^1.0.0", - "grunt-contrib-less": "^0.12.0", - "grunt-contrib-watch": "^0.6.1", - "grunt-eslint": "17.3.1", - "grunt-exec": "^0.4.6", - "grunt-jscs": "2.2.0", - "grunt-replace": "^0.9.2", - "grunt-styledocco": "^0.1.4", - "grunt-template-jasmine-requirejs": "^0.2.3", - "grunt-text-replace": "^0.4.0", - "imagemin-svgo": "^4.0.1", - "load-grunt-config": "^0.16.0", - "morgan": "^1.5.0", - "node-minify": "^1.0.1", - "path": "^0.11.14", - "serve-static": "^1.7.1", - "strip-json-comments": "^1.0.2", - "time-grunt": "^1.0.0", - "underscore": "^1.7.0", - "squirejs": "0.2.1" - }, - "engines": { - "node": ">=0.10.0" + "glob": "~7.1.1", + "grunt": "~1.0.1", + "grunt-autoprefixer": "~3.0.4", + "grunt-banner": "~0.6.0", + "grunt-contrib-clean": "~1.0.0", + "grunt-contrib-connect": "~1.0.2", + "grunt-contrib-cssmin": "~2.0.0", + "grunt-contrib-imagemin": "~1.0.1", + "grunt-contrib-jasmine": "~1.0.0", + "grunt-contrib-less": "~1.4.1", + "grunt-contrib-watch": "~1.0.0", + "grunt-eslint": "~19.0.0", + "grunt-exec": "~2.0.0", + "grunt-jscs": "~3.0.1", + "grunt-replace": "~1.0.1", + "grunt-styledocco": "~0.3.0", + "grunt-template-jasmine-requirejs": "~0.2.3", + "grunt-text-replace": "~0.4.0", + "imagemin-svgo": "~5.2.1", + "load-grunt-config": "~0.19.2", + "morgan": "~1.5.0", + "node-minify": "~2.0.3", + "path": "~0.12.7", + "serve-static": "~1.7.1", + "squirejs": "~0.2.1", + "strip-json-comments": "~2.0.1", + "time-grunt": "~1.0.0", + "underscore": "~1.7.0" } } From cf2e67e60c365388e1241a5e14670100efe0b1b0 Mon Sep 17 00:00:00 2001 From: Bartek Igielski Date: Thu, 30 Mar 2017 10:54:26 +0200 Subject: [PATCH 20/65] Fxing breaking changes after upgarde in mage-minify task --- dev/tools/grunt/configs/mage-minify.json | 5 ++--- dev/tools/grunt/tasks/mage-minify.js | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dev/tools/grunt/configs/mage-minify.json b/dev/tools/grunt/configs/mage-minify.json index 7f0c177722b31..1ddfa3910a3a8 100644 --- a/dev/tools/grunt/configs/mage-minify.json +++ b/dev/tools/grunt/configs/mage-minify.json @@ -1,8 +1,7 @@ { "legacy": { "options": { - "type": "yui-js", - "tempPath": "pub/static/" + "compressor": "yui-js" }, "files": { "<%= path.uglify.legacy %>": [ @@ -19,4 +18,4 @@ ] } } -} \ No newline at end of file +} diff --git a/dev/tools/grunt/tasks/mage-minify.js b/dev/tools/grunt/tasks/mage-minify.js index b337973975a58..1b25112b10d07 100644 --- a/dev/tools/grunt/tasks/mage-minify.js +++ b/dev/tools/grunt/tasks/mage-minify.js @@ -17,8 +17,8 @@ module.exports = function (grunt) { */ function getConfig(options, file) { return _.extend({ - fileIn: file.src, - fileOut: file.dest + input: file.src, + output: file.dest }, options); } @@ -43,7 +43,7 @@ module.exports = function (grunt) { } }; - new compressor.minify(config); + compressor.minify(config); }); }); }; From 82e3b2d37bfdacb5fa177dbc2dfe82c6f1f8f334 Mon Sep 17 00:00:00 2001 From: Bartek Igielski Date: Thu, 30 Mar 2017 10:55:37 +0200 Subject: [PATCH 21/65] Fxing breaking changes after upgarde in deploy task --- dev/tools/grunt/tasks/deploy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tools/grunt/tasks/deploy.js b/dev/tools/grunt/tasks/deploy.js index 01bb28f0510ac..2bfc73bb3357f 100644 --- a/dev/tools/grunt/tasks/deploy.js +++ b/dev/tools/grunt/tasks/deploy.js @@ -20,7 +20,7 @@ module.exports = function (grunt) { ok('"pub/static" is empty.'); log('Deploying Magento application...'); - deploy = spawn('php', ['bin/magento', 'setup:static-content:deploy -f']); + deploy = spawn('php', ['bin/magento', 'setup:static-content:deploy', '-f']); deploy.stdout.on('data', function (data) { log(data); From 142b6f47d1660822ca20985235fc12e9f6936da6 Mon Sep 17 00:00:00 2001 From: Petar Sambolek Date: Fri, 31 Mar 2017 21:58:53 +0200 Subject: [PATCH 22/65] Fix Google Analytics typo in printing Account Number on frontend, fixes #7549 --- app/code/Magento/GoogleAnalytics/Block/Ga.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/GoogleAnalytics/Block/Ga.php b/app/code/Magento/GoogleAnalytics/Block/Ga.php index d6b4bbdba693d..7bd73ae90b168 100644 --- a/app/code/Magento/GoogleAnalytics/Block/Ga.php +++ b/app/code/Magento/GoogleAnalytics/Block/Ga.php @@ -86,7 +86,7 @@ public function getPageTrackingCode($accountId) } return "\nga('create', '" . $this->escapeHtmlAttr($accountId, false) - . ", 'auto');{$anonymizeIp}\nga('send', 'pageview'{$optPageURL});\n"; + . "', 'auto');{$anonymizeIp}\nga('send', 'pageview'{$optPageURL});\n"; } /** From a7934d218dea4f071dc7b18c8ba266b0ae1abb4d Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Sat, 1 Apr 2017 14:04:34 -0700 Subject: [PATCH 23/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - Create class to collect DI configuration information --- .../Developer/Model/Di/Information.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 app/code/Magento/Developer/Model/Di/Information.php diff --git a/app/code/Magento/Developer/Model/Di/Information.php b/app/code/Magento/Developer/Model/Di/Information.php new file mode 100644 index 0000000000000..6e76d8a8c163a --- /dev/null +++ b/app/code/Magento/Developer/Model/Di/Information.php @@ -0,0 +1,33 @@ +objectManagerConfig = $objectManagerConfig; + } + + /** + * Get info on the preference for the class + * + * @param string $className + * @return string + */ + public function getPreference($className) + { + return $this->objectManagerConfig->getPreference($className); + } +} \ No newline at end of file From 7e6d451c78b3d4ab6eda42f72da793e9ebd6010f Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Sat, 1 Apr 2017 14:22:44 -0700 Subject: [PATCH 24/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - Create method to retrieve constructor parameters info --- .../Developer/Model/Di/Information.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Developer/Model/Di/Information.php b/app/code/Magento/Developer/Model/Di/Information.php index 6e76d8a8c163a..18464712ac236 100644 --- a/app/code/Magento/Developer/Model/Di/Information.php +++ b/app/code/Magento/Developer/Model/Di/Information.php @@ -12,6 +12,11 @@ class Information */ private $objectManagerConfig; + /** + * @var string[] + */ + private $preferences = []; + /** * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig */ @@ -28,6 +33,20 @@ public function __construct(\Magento\Framework\ObjectManager\ConfigInterface $ob */ public function getPreference($className) { - return $this->objectManagerConfig->getPreference($className); + if (!isset($this->preferences[$className])) { + $this->preferences[$className] = $this->objectManagerConfig->getPreference($className); + } + return $this->preferences[$className]; + } + + /** + * Retrieve parameters of the constructor for the class preference object + * + * @param $className + * @return array|null + */ + public function getConstructorParameters($className) + { + return $this->objectManagerConfig->getArguments($className); } } \ No newline at end of file From 368b26eb137de5dc01f45a7ac33c35f4dcd393c5 Mon Sep 17 00:00:00 2001 From: andra lungu Date: Sat, 1 Apr 2017 14:27:28 -0700 Subject: [PATCH 25/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - Create Class for Di info command --- .../Console/Command/DiInfoCommand.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 app/code/Magento/Developer/Console/Command/DiInfoCommand.php diff --git a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php new file mode 100644 index 0000000000000..250d0541a25a0 --- /dev/null +++ b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php @@ -0,0 +1,56 @@ + + * Date: 01/04/17 + * Time: 14.02 + */ + +namespace Magento\Developer\Console\Command; + +use Magento\Developer\Model\Di\Information; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Exception\InvalidArgumentException; + +class DiInfoCommand extends Command +{ + /** + * Command name + */ + const COMMAND_NAME = 'dev:di:info'; + + /** + * input name + */ + const CLASS_NAME = 'class'; + + /** + * @var Information + */ + private $diInformation; + + /** + * @param Information $diInformation + */ + public function __construct( + Information $diInformation + ) { + $this->diInformation = $diInformation; + parent::__construct(); + } + + /** + * {@inheritdoc} + * @throws InvalidArgumentException + */ + protected function configure() + { + $this->setName(self::COMMAND_NAME) + ->setDescription('Generates the list of preferences for the class') + ->setDefinition([ + new InputArgument(self::CLASS_NAME, InputArgument::REQUIRED, 'Class name') + ]); + + parent::configure(); + } +} \ No newline at end of file From 4dc7a922da785a514cfc86240eb45bade9dc48fe Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Sat, 1 Apr 2017 14:36:20 -0700 Subject: [PATCH 26/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - Create method to retrieve virtual types of the class and its preference --- .../Developer/Model/Di/Information.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Developer/Model/Di/Information.php b/app/code/Magento/Developer/Model/Di/Information.php index 18464712ac236..b8d3775e10807 100644 --- a/app/code/Magento/Developer/Model/Di/Information.php +++ b/app/code/Magento/Developer/Model/Di/Information.php @@ -40,13 +40,32 @@ public function getPreference($className) } /** - * Retrieve parameters of the constructor for the class preference object + * Retrieve parameters of the constructor for the preference of the class * * @param $className * @return array|null */ public function getConstructorParameters($className) { - return $this->objectManagerConfig->getArguments($className); + $preferenceClass = $this->getPreference($className); + return $this->objectManagerConfig->getArguments($preferenceClass); + } + + /** + * Retrieve virtual types for the class and the preference of the class + * + * @param $className + * @return array + */ + public function getVirtualTypes($className) + { + $preference = $this->getPreference($className); + $virtualTypes = []; + foreach ($this->objectManagerConfig->getVirtualTypes() as $virtualType => $baseName) { + if ($baseName == $className || $baseName == $preference) { + $virtualTypes[] = $virtualType; + } + } + return $virtualTypes; } } \ No newline at end of file From 257476523cd19bf57ffb2c85a3458f23e0569d3b Mon Sep 17 00:00:00 2001 From: andra lungu Date: Sat, 1 Apr 2017 15:04:54 -0700 Subject: [PATCH 27/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - added in di.xml the dev_di_info command --- app/code/Magento/Developer/etc/di.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Developer/etc/di.xml b/app/code/Magento/Developer/etc/di.xml index 550ea10e6be9f..d384c39ebbe50 100644 --- a/app/code/Magento/Developer/etc/di.xml +++ b/app/code/Magento/Developer/etc/di.xml @@ -96,6 +96,7 @@ Magento\Developer\Console\Command\SourceThemeDeployCommand Magento\Developer\Console\Command\XmlConverterCommand Magento\Developer\Console\Command\XmlCatalogGenerateCommand + Magento\Developer\Console\Command\DiInfoCommand From 551dd4ef01276db08d556862a70aa8c9eff44087 Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Sat, 1 Apr 2017 15:27:44 -0700 Subject: [PATCH 28/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - added the execute method --- .../Console/Command/DiInfoCommand.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php index 250d0541a25a0..7b9aab02d32f1 100644 --- a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php +++ b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php @@ -11,6 +11,9 @@ use Magento\Developer\Model\Di\Information; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Exception\InvalidArgumentException; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputArgument; class DiInfoCommand extends Command { @@ -46,11 +49,24 @@ public function __construct( protected function configure() { $this->setName(self::COMMAND_NAME) - ->setDescription('Generates the list of preferences for the class') + ->setDescription('Provides information on Dependency Injection configuration for the Command.') ->setDefinition([ new InputArgument(self::CLASS_NAME, InputArgument::REQUIRED, 'Class name') ]); parent::configure(); } + + /** + * {@inheritdoc} + * @throws \InvalidArgumentException + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $className = $input->getArgument(self::CLASS_NAME); + $output->writeln(sprintf('DI configuration for the class %s', $className)); + $output->writeln(sprintf('- Preference: %s', $this->diInformation->getPreference($className))); + //$output->writeln(sprintf('- Constructor Parameters: %s', $this->diInformation->getPreference($className))); + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; + } } \ No newline at end of file From 2ebd560fb456bbec228ba5519a50c6b08159997a Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Sat, 1 Apr 2017 19:25:07 -0700 Subject: [PATCH 29/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - format the output of the command --- .../Console/Command/DiInfoCommand.php | 29 +++++++++++++++++-- .../Developer/Model/Di/Information.php | 26 +++++++++++++++-- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php index 7b9aab02d32f1..02c3b6c4ded36 100644 --- a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php +++ b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Helper\Table; class DiInfoCommand extends Command { @@ -64,9 +65,33 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $className = $input->getArgument(self::CLASS_NAME); + $output->writeln(''); $output->writeln(sprintf('DI configuration for the class %s', $className)); - $output->writeln(sprintf('- Preference: %s', $this->diInformation->getPreference($className))); - //$output->writeln(sprintf('- Constructor Parameters: %s', $this->diInformation->getPreference($className))); + $output->writeln(''); + $output->writeln(sprintf('Preference: %s', $this->diInformation->getPreference($className))); + $output->writeln(''); + $output->writeln("Constructor Parameters:"); + $parameters = []; + $diParametersConfiguration = $this->diInformation->getConfiguredConstructorParameters($className); + foreach ($this->diInformation->getConstructorParameters($className) as $parameter) { + $paramArray = [$parameter[0], $parameter[1], '']; + if (isset($diParametersConfiguration[$parameter[0]])) { + $paramArray[2] = $diParametersConfiguration[$parameter[0]]['instance']; + } + $parameters[] = $paramArray; + } + $table = new Table($output); + $table + ->setHeaders(array('Name', 'Type', 'Configured Type')) + ->setRows($parameters); + + $output->writeln($table->render()); + $output->writeln(''); + $output->writeln("Virtual Types:"); + foreach ($this->diInformation->getVirtualTypes($className) as $virtualType) { + $output->writeln(' ' . $virtualType); + } + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } \ No newline at end of file diff --git a/app/code/Magento/Developer/Model/Di/Information.php b/app/code/Magento/Developer/Model/Di/Information.php index b8d3775e10807..715a70da93cb0 100644 --- a/app/code/Magento/Developer/Model/Di/Information.php +++ b/app/code/Magento/Developer/Model/Di/Information.php @@ -17,12 +17,21 @@ class Information */ private $preferences = []; + /** + * @var \Magento\Framework\ObjectManager\DefinitionInterface + */ + private $definitions; + /** * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig + * @param \Magento\Framework\ObjectManager\DefinitionInterface $definitions */ - public function __construct(\Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig) - { + public function __construct( + \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, + \Magento\Framework\ObjectManager\DefinitionInterface $definitions + ) { $this->objectManagerConfig = $objectManagerConfig; + $this->definitions = $definitions; } /** @@ -46,6 +55,19 @@ public function getPreference($className) * @return array|null */ public function getConstructorParameters($className) + { + $preferenceClass = $this->getPreference($className); + $parameters = $this->definitions->getParameters($preferenceClass); + return $parameters; + } + + /** + * Retrieve configured types of parameters of the constructor for the preference of the class + * + * @param $className + * @return array|null + */ + public function getConfiguredConstructorParameters($className) { $preferenceClass = $this->getPreference($className); return $this->objectManagerConfig->getArguments($preferenceClass); From 789cb19b03124dd6e7e6f733bdbf853998b7e546 Mon Sep 17 00:00:00 2001 From: andra lungu Date: Sat, 1 Apr 2017 19:35:14 -0700 Subject: [PATCH 30/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - added pluginlist model to recover the information about the plugin for the specified class --- .../Developer/Model/Di/Information.php | 22 +++- .../Magento/Developer/Model/Di/PluginList.php | 116 ++++++++++++++++++ 2 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Developer/Model/Di/PluginList.php diff --git a/app/code/Magento/Developer/Model/Di/Information.php b/app/code/Magento/Developer/Model/Di/Information.php index b8d3775e10807..72c71b5d71300 100644 --- a/app/code/Magento/Developer/Model/Di/Information.php +++ b/app/code/Magento/Developer/Model/Di/Information.php @@ -5,6 +5,8 @@ */ namespace Magento\Developer\Model\Di; +use Magento\Developer\Model\Di\PluginList; + class Information { /** @@ -12,6 +14,11 @@ class Information */ private $objectManagerConfig; + /** + * @var \Magento\Developer\Model\Di\PluginList + */ + + private $pluginList; /** * @var string[] */ @@ -20,9 +27,12 @@ class Information /** * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig */ - public function __construct(\Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig) + public function __construct(\Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, + \Magento\Developer\Model\Di\PluginList $pluginList + ) { $this->objectManagerConfig = $objectManagerConfig; + $this->pluginList = $pluginList; } /** @@ -68,4 +78,14 @@ public function getVirtualTypes($className) } return $virtualTypes; } + + /** + * @param $className + * @return array + */ + public function getPlugins($className) + { + return $this->pluginList->getPluginsListByClass($className); + + } } \ No newline at end of file diff --git a/app/code/Magento/Developer/Model/Di/PluginList.php b/app/code/Magento/Developer/Model/Di/PluginList.php new file mode 100644 index 0000000000000..96d4270b78766 --- /dev/null +++ b/app/code/Magento/Developer/Model/Di/PluginList.php @@ -0,0 +1,116 @@ + + * Date: 01/04/17 + * Time: 14.02 + */ + +namespace Magento\Developer\Model\Di; + +use Magento\Framework\Interception; +use Magento\Framework\Interception\DefinitionInterface; + +/** + * Provides plugin list configuration + */ +class PluginList extends Interception\PluginList\PluginList +{ + /** + * @var array + */ + private $pluginList = [ + DefinitionInterface::LISTENER_BEFORE => [], + DefinitionInterface::LISTENER_AROUND => [], + DefinitionInterface::LISTENER_AFTER => [] + ]; + /** + * @var array + */ + private $interceptedClasses; + + /** + * Returns plugins config + * + * @return array + */ + public function getPluginsConfig() + { + $this->_loadScopedData(); + + return $this->_inherited; + } + + /** + * Sets scope priority scheme + * + * @param array $areaCodes + * + * @return void + */ + public function setScopePriorityScheme($areaCodes) + { + $this->_scopePriorityScheme = $areaCodes; + } + + /** + * Whether scope code is current scope code + * + * @param string $scopeCode + * + * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + protected function isCurrentScope($scopeCode) + { + return false; + } + + + private function getPlugins($type) + { + $this->_loadScopedData(); + if (!isset($this->_inherited[$type]) && !array_key_exists($type, $this->_inherited)) { + $this->_inheritPlugins($type); + } + return $this->_inherited[$type]; + } + + + /** + * @param $className + * + * @return array + * @throws \InvalidArgumentException + */ + public function getPluginsListByClass($className) + { + + $this->getPlugins($className); + + foreach ($this->_inherited[$className] as $pluginKey => $plugin) + { + foreach ($this->_definitions->getMethodList($plugin['instance']) as $pluginMethod => $methodTypes) { + + if ($methodTypes & DefinitionInterface::LISTENER_AROUND) { + if(!array_key_exists($plugin['instance'],$this->pluginList[DefinitionInterface::LISTENER_AROUND])) + $this->pluginList[DefinitionInterface::LISTENER_AROUND][$plugin['instance']] = []; + $this->pluginList[DefinitionInterface::LISTENER_AROUND][$plugin['instance']][] = $pluginMethod ; + + } + if ($methodTypes & DefinitionInterface::LISTENER_BEFORE) { + if(!array_key_exists($plugin['instance'],$this->pluginList[DefinitionInterface::LISTENER_BEFORE])) + $this->pluginList[DefinitionInterface::LISTENER_BEFORE][$plugin['instance']] = []; + $this->pluginList[DefinitionInterface::LISTENER_BEFORE][$plugin['instance']][] = $pluginMethod ; + + } + if ($methodTypes & DefinitionInterface::LISTENER_AFTER) { + if(!array_key_exists($plugin['instance'],$this->pluginList[DefinitionInterface::LISTENER_AFTER])) + $this->pluginList[DefinitionInterface::LISTENER_AFTER][$plugin['instance']] = []; + $this->pluginList[DefinitionInterface::LISTENER_AFTER][$plugin['instance']][] = $pluginMethod ; + } + } + } + return $this->pluginList; + } +} From 2608b1deebe4bd1ffb2cb6bfad758aa65e43cd6f Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Sat, 1 Apr 2017 20:15:44 -0700 Subject: [PATCH 31/65] Merge branch 'cli-info-di' of https://github.com/springerin/magento2 into cli-info-di # Conflicts: # app/code/Magento/Developer/Model/Di/Information.php --- .../Console/Command/DiInfoCommand.php | 23 +++------ .../Developer/Model/Di/Information.php | 51 ++++++++++++++++--- .../Magento/Developer/Model/Di/PluginList.php | 44 +++++++++------- 3 files changed, 77 insertions(+), 41 deletions(-) diff --git a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php index 02c3b6c4ded36..6ad48b2cdeb67 100644 --- a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php +++ b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php @@ -71,27 +71,20 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(sprintf('Preference: %s', $this->diInformation->getPreference($className))); $output->writeln(''); $output->writeln("Constructor Parameters:"); - $parameters = []; - $diParametersConfiguration = $this->diInformation->getConfiguredConstructorParameters($className); - foreach ($this->diInformation->getConstructorParameters($className) as $parameter) { - $paramArray = [$parameter[0], $parameter[1], '']; - if (isset($diParametersConfiguration[$parameter[0]])) { - $paramArray[2] = $diParametersConfiguration[$parameter[0]]['instance']; - } - $parameters[] = $paramArray; - } $table = new Table($output); $table ->setHeaders(array('Name', 'Type', 'Configured Type')) - ->setRows($parameters); + ->setRows($this->diInformation->getParameters($className)); $output->writeln($table->render()); - $output->writeln(''); - $output->writeln("Virtual Types:"); - foreach ($this->diInformation->getVirtualTypes($className) as $virtualType) { - $output->writeln(' ' . $virtualType); + $virtualTypes = $this->diInformation->getVirtualTypes($className); + if (!empty($virtualTypes)) { + $output->writeln(''); + $output->writeln("Virtual Types:"); + foreach ($this->diInformation->getVirtualTypes($className) as $virtualType) { + $output->writeln(' ' . $virtualType); + } } - return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } \ No newline at end of file diff --git a/app/code/Magento/Developer/Model/Di/Information.php b/app/code/Magento/Developer/Model/Di/Information.php index 2f848b0be4899..d9e3aca478dd1 100644 --- a/app/code/Magento/Developer/Model/Di/Information.php +++ b/app/code/Magento/Developer/Model/Di/Information.php @@ -17,13 +17,18 @@ class Information /** * @var \Magento\Developer\Model\Di\PluginList */ - private $pluginList; + /** * @var string[] */ private $preferences = []; + /** + * @var array + */ + private $virtualTypes = []; + /** * @var \Magento\Framework\ObjectManager\DefinitionInterface */ @@ -63,20 +68,40 @@ public function getPreference($className) * @param $className * @return array|null */ - public function getConstructorParameters($className) + private function getConstructorParameters($className) { $preferenceClass = $this->getPreference($className); $parameters = $this->definitions->getParameters($preferenceClass); return $parameters; } + /** + * Retrieve array of parameters for the class constructor + * + * @param $className + * @return array + */ + public function getParameters($className) + { + $result = []; + $diConfiguration = $this->getConfiguredConstructorParameters($className); + foreach ($this->getConstructorParameters($className) as $parameter) { + $paramArray = [$parameter[0], $parameter[1], '']; + if (isset($diConfiguration[$parameter[0]])) { + $paramArray[2] = $diConfiguration[$parameter[0]]['instance']; + } + $result[] = $paramArray; + } + return $result; + } + /** * Retrieve configured types of parameters of the constructor for the preference of the class * * @param $className * @return array|null */ - public function getConfiguredConstructorParameters($className) + private function getConfiguredConstructorParameters($className) { $preferenceClass = $this->getPreference($className); return $this->objectManagerConfig->getArguments($preferenceClass); @@ -91,13 +116,15 @@ public function getConfiguredConstructorParameters($className) public function getVirtualTypes($className) { $preference = $this->getPreference($className); - $virtualTypes = []; - foreach ($this->objectManagerConfig->getVirtualTypes() as $virtualType => $baseName) { - if ($baseName == $className || $baseName == $preference) { - $virtualTypes[] = $virtualType; + if (!isset($this->virtualTypes[$className])) { + $this->virtualTypes[$className] = []; + foreach ($this->objectManagerConfig->getVirtualTypes() as $virtualType => $baseName) { + if ($baseName == $className || $baseName == $preference) { + $this->virtualTypes[$className][] = $virtualType; + } } } - return $virtualTypes; + return $this->virtualTypes[$className]; } /** @@ -107,6 +134,14 @@ public function getVirtualTypes($className) public function getPlugins($className) { return $this->pluginList->getPluginsListByClass($className); + } + /** + * Is the class a virtual type + */ + public function isVirtualType($className) + { + $virtualTypes = $this->objectManagerConfig->getVirtualTypes(); + return isset($virtualTypes[$className]); } } \ No newline at end of file diff --git a/app/code/Magento/Developer/Model/Di/PluginList.php b/app/code/Magento/Developer/Model/Di/PluginList.php index 96d4270b78766..be25e680bf7a6 100644 --- a/app/code/Magento/Developer/Model/Di/PluginList.php +++ b/app/code/Magento/Developer/Model/Di/PluginList.php @@ -1,9 +1,7 @@ - * Date: 01/04/17 - * Time: 14.02 + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. */ namespace Magento\Developer\Model\Di; @@ -24,10 +22,6 @@ class PluginList extends Interception\PluginList\PluginList DefinitionInterface::LISTENER_AROUND => [], DefinitionInterface::LISTENER_AFTER => [] ]; - /** - * @var array - */ - private $interceptedClasses; /** * Returns plugins config @@ -66,7 +60,12 @@ protected function isCurrentScope($scopeCode) return false; } - + /** + * Load the plugins information + * + * @param $type + * @return array + */ private function getPlugins($type) { $this->_loadScopedData(); @@ -78,35 +77,44 @@ private function getPlugins($type) /** - * @param $className + * Return the list of plugins for the class * + * @param $className * @return array * @throws \InvalidArgumentException */ public function getPluginsListByClass($className) { - $this->getPlugins($className); - - foreach ($this->_inherited[$className] as $pluginKey => $plugin) - { + foreach ($this->_inherited[$className] as $pluginKey => $plugin) { foreach ($this->_definitions->getMethodList($plugin['instance']) as $pluginMethod => $methodTypes) { - if ($methodTypes & DefinitionInterface::LISTENER_AROUND) { - if(!array_key_exists($plugin['instance'],$this->pluginList[DefinitionInterface::LISTENER_AROUND])) + if (!array_key_exists( + $plugin['instance'], + $this->pluginList[DefinitionInterface::LISTENER_AROUND]) + ) { $this->pluginList[DefinitionInterface::LISTENER_AROUND][$plugin['instance']] = []; + } $this->pluginList[DefinitionInterface::LISTENER_AROUND][$plugin['instance']][] = $pluginMethod ; } if ($methodTypes & DefinitionInterface::LISTENER_BEFORE) { - if(!array_key_exists($plugin['instance'],$this->pluginList[DefinitionInterface::LISTENER_BEFORE])) + if (!array_key_exists( + $plugin['instance'], + $this->pluginList[DefinitionInterface::LISTENER_BEFORE]) + ) { $this->pluginList[DefinitionInterface::LISTENER_BEFORE][$plugin['instance']] = []; + } $this->pluginList[DefinitionInterface::LISTENER_BEFORE][$plugin['instance']][] = $pluginMethod ; } if ($methodTypes & DefinitionInterface::LISTENER_AFTER) { - if(!array_key_exists($plugin['instance'],$this->pluginList[DefinitionInterface::LISTENER_AFTER])) + if (!array_key_exists( + $plugin['instance'], + $this->pluginList[DefinitionInterface::LISTENER_AFTER]) + ) { $this->pluginList[DefinitionInterface::LISTENER_AFTER][$plugin['instance']] = []; + } $this->pluginList[DefinitionInterface::LISTENER_AFTER][$plugin['instance']][] = $pluginMethod ; } } From f580225e12fe6d39101ca3c3c2f2689a543e1010 Mon Sep 17 00:00:00 2001 From: andra lungu Date: Sat, 1 Apr 2017 20:28:34 -0700 Subject: [PATCH 32/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - added type name to plugin method instead of id --- .../Console/Command/DiInfoCommand.php | 19 +++++++++++++++ .../Magento/Developer/Model/Di/PluginList.php | 24 +++++++++---------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php index 6ad48b2cdeb67..c14be0fb5b512 100644 --- a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php +++ b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php @@ -85,6 +85,25 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(' ' . $virtualType); } } + + $output->writeln(''); + $output->writeln("Plugins:"); + $plugins = $this->diInformation->getPlugins($className); + $parameters = []; + foreach ($plugins as $type => $plugin) { + foreach ($plugin as $instance => $pluginMethods){ + foreach ($pluginMethods as $pluginMethod){ + $parameters[] = [$instance, $pluginMethod, $type]; + } + } + } + + $table = new Table($output); + $table + ->setHeaders(array('Plugin', 'Method', 'Type')) + ->setRows($parameters); + + $output->writeln($table->render()); return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } \ No newline at end of file diff --git a/app/code/Magento/Developer/Model/Di/PluginList.php b/app/code/Magento/Developer/Model/Di/PluginList.php index be25e680bf7a6..0e929eeb811ff 100644 --- a/app/code/Magento/Developer/Model/Di/PluginList.php +++ b/app/code/Magento/Developer/Model/Di/PluginList.php @@ -18,9 +18,9 @@ class PluginList extends Interception\PluginList\PluginList * @var array */ private $pluginList = [ - DefinitionInterface::LISTENER_BEFORE => [], - DefinitionInterface::LISTENER_AROUND => [], - DefinitionInterface::LISTENER_AFTER => [] + 'before' => [], + 'around' => [], + 'after' => [] ]; /** @@ -91,31 +91,31 @@ public function getPluginsListByClass($className) if ($methodTypes & DefinitionInterface::LISTENER_AROUND) { if (!array_key_exists( $plugin['instance'], - $this->pluginList[DefinitionInterface::LISTENER_AROUND]) + $this->pluginList['around']) ) { - $this->pluginList[DefinitionInterface::LISTENER_AROUND][$plugin['instance']] = []; + $this->pluginList['around'][$plugin['instance']] = []; } - $this->pluginList[DefinitionInterface::LISTENER_AROUND][$plugin['instance']][] = $pluginMethod ; + $this->pluginList['around'][$plugin['instance']][] = $pluginMethod ; } if ($methodTypes & DefinitionInterface::LISTENER_BEFORE) { if (!array_key_exists( $plugin['instance'], - $this->pluginList[DefinitionInterface::LISTENER_BEFORE]) + $this->pluginList['before']) ) { - $this->pluginList[DefinitionInterface::LISTENER_BEFORE][$plugin['instance']] = []; + $this->pluginList['before'][$plugin['instance']] = []; } - $this->pluginList[DefinitionInterface::LISTENER_BEFORE][$plugin['instance']][] = $pluginMethod ; + $this->pluginList['before'][$plugin['instance']][] = $pluginMethod ; } if ($methodTypes & DefinitionInterface::LISTENER_AFTER) { if (!array_key_exists( $plugin['instance'], - $this->pluginList[DefinitionInterface::LISTENER_AFTER]) + $this->pluginList['after']) ) { - $this->pluginList[DefinitionInterface::LISTENER_AFTER][$plugin['instance']] = []; + $this->pluginList['after'][$plugin['instance']] = []; } - $this->pluginList[DefinitionInterface::LISTENER_AFTER][$plugin['instance']][] = $pluginMethod ; + $this->pluginList['after'][$plugin['instance']][] = $pluginMethod ; } } } From e9c71c07b8dcc56b8e56440a8e952d8c273b31e5 Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Sat, 1 Apr 2017 20:33:48 -0700 Subject: [PATCH 33/65] Merge branch 'cli-info-di' of https://github.com/springerin/magento2 into cli-info-di --- .../Console/Command/DiInfoCommand.php | 39 ++++++++++++------- .../Developer/Model/Di/Information.php | 26 ++++++++++--- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php index 6ad48b2cdeb67..79d15d009d4ad 100644 --- a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php +++ b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php @@ -67,24 +67,35 @@ protected function execute(InputInterface $input, OutputInterface $output) $className = $input->getArgument(self::CLASS_NAME); $output->writeln(''); $output->writeln(sprintf('DI configuration for the class %s', $className)); - $output->writeln(''); - $output->writeln(sprintf('Preference: %s', $this->diInformation->getPreference($className))); - $output->writeln(''); - $output->writeln("Constructor Parameters:"); - $table = new Table($output); - $table - ->setHeaders(array('Name', 'Type', 'Configured Type')) - ->setRows($this->diInformation->getParameters($className)); - $output->writeln($table->render()); - $virtualTypes = $this->diInformation->getVirtualTypes($className); - if (!empty($virtualTypes)) { + if ($this->diInformation->isVirtualType($className)) { + $output->writeln( + sprintf('It is Virtual Type for the Class %s', $this->diInformation->getVirtualTypeBase($className)) + ); + } else { + $preference = $this->diInformation->getPreference($className); $output->writeln(''); - $output->writeln("Virtual Types:"); - foreach ($this->diInformation->getVirtualTypes($className) as $virtualType) { - $output->writeln(' ' . $virtualType); + $output->writeln(sprintf('Preference: %s', $preference)); + $output->writeln(''); + $output->writeln("Constructor Parameters:"); + + $virtualTypes = $this->diInformation->getVirtualTypes($preference); + if (!empty($virtualTypes)) { + $output->writeln(''); + $output->writeln("Virtual Types:"); + foreach ($this->diInformation->getVirtualTypes($className) as $virtualType) { + $output->writeln(' ' . $virtualType); + } } + + $table = new Table($output); + $table + ->setHeaders(array('Name', 'Type', 'Configured Type')) + ->setRows($this->diInformation->getParameters($preference)); + + $output->writeln($table->render()); } + return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } \ No newline at end of file diff --git a/app/code/Magento/Developer/Model/Di/Information.php b/app/code/Magento/Developer/Model/Di/Information.php index d9e3aca478dd1..a829382ca5963 100644 --- a/app/code/Magento/Developer/Model/Di/Information.php +++ b/app/code/Magento/Developer/Model/Di/Information.php @@ -70,8 +70,7 @@ public function getPreference($className) */ private function getConstructorParameters($className) { - $preferenceClass = $this->getPreference($className); - $parameters = $this->definitions->getParameters($preferenceClass); + $parameters = $this->definitions->getParameters($className); return $parameters; } @@ -103,8 +102,7 @@ public function getParameters($className) */ private function getConfiguredConstructorParameters($className) { - $preferenceClass = $this->getPreference($className); - return $this->objectManagerConfig->getArguments($preferenceClass); + return $this->objectManagerConfig->getArguments($className); } /** @@ -128,7 +126,7 @@ public function getVirtualTypes($className) } /** - * @param $className + * @param string $className * @return array */ public function getPlugins($className) @@ -138,10 +136,28 @@ public function getPlugins($className) /** * Is the class a virtual type + * + * @param string $className + * @return boolean */ public function isVirtualType($className) { $virtualTypes = $this->objectManagerConfig->getVirtualTypes(); return isset($virtualTypes[$className]); } + + /** + * Get base class for the Virtual Type + * + * @param string $className + * @return string|boolean + */ + public function getVirtualTypeBase($className) + { + $virtualTypes = $this->objectManagerConfig->getVirtualTypes(); + if (isset($virtualTypes[$className])) { + return $virtualTypes[$className]; + } + return false; + } } \ No newline at end of file From 2da051d79e9f8a10c11db01589790beed5c2fd31 Mon Sep 17 00:00:00 2001 From: andra lungu Date: Sat, 1 Apr 2017 20:41:02 -0700 Subject: [PATCH 34/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - added check existence of className in the inherited array --- app/code/Magento/Developer/Model/Di/PluginList.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/Developer/Model/Di/PluginList.php b/app/code/Magento/Developer/Model/Di/PluginList.php index 0e929eeb811ff..7950cd0eac8ba 100644 --- a/app/code/Magento/Developer/Model/Di/PluginList.php +++ b/app/code/Magento/Developer/Model/Di/PluginList.php @@ -86,6 +86,8 @@ private function getPlugins($type) public function getPluginsListByClass($className) { $this->getPlugins($className); + if(!isset($this->_inherited[$className])) + return $this->pluginList; foreach ($this->_inherited[$className] as $pluginKey => $plugin) { foreach ($this->_definitions->getMethodList($plugin['instance']) as $pluginMethod => $methodTypes) { if ($methodTypes & DefinitionInterface::LISTENER_AROUND) { From b85396949d917c67ec2814c806b998dbfd2fe0e0 Mon Sep 17 00:00:00 2001 From: andra lungu Date: Sat, 1 Apr 2017 20:44:58 -0700 Subject: [PATCH 35/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - added plugins info about preference --- .../Console/Command/DiInfoCommand.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php index 331227fc6b8be..423c6f956d0af 100644 --- a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php +++ b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php @@ -113,6 +113,25 @@ protected function execute(InputInterface $input, OutputInterface $output) ->setRows($parameters); $output->writeln($table->render()); + + $output->writeln(''); + $output->writeln("Preference Plugins:"); + $plugins = $this->diInformation->getPlugins($preference); + $parameters = []; + foreach ($plugins as $type => $plugin) { + foreach ($plugin as $instance => $pluginMethods){ + foreach ($pluginMethods as $pluginMethod){ + $parameters[] = [$instance, $pluginMethod, $type]; + } + } + } + + $table = new Table($output); + $table + ->setHeaders(array('Plugin', 'Method', 'Type')) + ->setRows($parameters); + + $output->writeln($table->render()); } return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } From 7cef5375bf0d6be11521f48a090f0f1c2641d1ee Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Sun, 2 Apr 2017 06:35:08 -0700 Subject: [PATCH 36/65] Merge branch 'cli-info-di' of https://github.com/springerin/magento2 into cli-info-di - Added support for the virtual types --- .../Console/Command/DiInfoCommand.php | 75 +++++++++---------- .../Developer/Model/Di/Information.php | 18 ++++- 2 files changed, 52 insertions(+), 41 deletions(-) diff --git a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php index 331227fc6b8be..a9d709839cbfe 100644 --- a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php +++ b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php @@ -68,52 +68,49 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(''); $output->writeln(sprintf('DI configuration for the class %s', $className)); - if ($this->diInformation->isVirtualType($className)) { - $output->writeln( - sprintf('It is Virtual Type for the Class %s', $this->diInformation->getVirtualTypeBase($className)) - ); - } else { - $preference = $this->diInformation->getPreference($className); - $output->writeln(''); - $output->writeln(sprintf('Preference: %s', $preference)); + $output->writeln( + sprintf('It is Virtual Type for the Class %s', $this->diInformation->getVirtualTypeBase($className)) + ); + + $preference = $this->diInformation->getPreference($className); + $output->writeln(''); + $output->writeln(sprintf('Preference: %s', $preference)); + $output->writeln(''); + $output->writeln("Constructor Parameters:"); + $paramsTable = new Table($output); + $paramsTable + ->setHeaders(['Name', 'Type', 'Configured Type']); + $paramsTable->setRows([]); + $output->writeln($paramsTable->render()); + + $virtualTypes = $this->diInformation->getVirtualTypes($preference); + if (!empty($virtualTypes)) { $output->writeln(''); - $output->writeln("Constructor Parameters:"); - - $virtualTypes = $this->diInformation->getVirtualTypes($preference); - if (!empty($virtualTypes)) { - $output->writeln(''); - $output->writeln("Virtual Types:"); - foreach ($this->diInformation->getVirtualTypes($className) as $virtualType) { - $output->writeln(' ' . $virtualType); - } + $output->writeln("Virtual Types:"); + foreach ($this->diInformation->getVirtualTypes($className) as $virtualType) { + $output->writeln(' ' . $virtualType); } + } - $table = new Table($output); - $table - ->setHeaders(array('Name', 'Type', 'Configured Type')) - ->setRows($this->diInformation->getParameters($preference)); - - $output->writeln($table->render()); - - $output->writeln(''); - $output->writeln("Plugins:"); - $plugins = $this->diInformation->getPlugins($className); - $parameters = []; - foreach ($plugins as $type => $plugin) { - foreach ($plugin as $instance => $pluginMethods){ - foreach ($pluginMethods as $pluginMethod){ - $parameters[] = [$instance, $pluginMethod, $type]; - } + $output->writeln(''); + $output->writeln("Plugins:"); + $plugins = $this->diInformation->getPlugins($className); + $parameters = []; + foreach ($plugins as $type => $plugin) { + foreach ($plugin as $instance => $pluginMethods){ + foreach ($pluginMethods as $pluginMethod){ + $parameters[] = [$instance, $pluginMethod, $type]; } } + } - $table = new Table($output); - $table - ->setHeaders(array('Plugin', 'Method', 'Type')) - ->setRows($parameters); + $table = new Table($output); + $table + ->setHeaders(array('Plugin', 'Method', 'Type')) + ->setRows($parameters); + + $output->writeln($table->render()); - $output->writeln($table->render()); - } return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } } \ No newline at end of file diff --git a/app/code/Magento/Developer/Model/Di/Information.php b/app/code/Magento/Developer/Model/Di/Information.php index a829382ca5963..e826ca5f1f0b1 100644 --- a/app/code/Magento/Developer/Model/Di/Information.php +++ b/app/code/Magento/Developer/Model/Di/Information.php @@ -84,10 +84,24 @@ public function getParameters($className) { $result = []; $diConfiguration = $this->getConfiguredConstructorParameters($className); - foreach ($this->getConstructorParameters($className) as $parameter) { + $originalParameters = $this->isVirtualType($className) ? + $this->getConstructorParameters($this->getVirtualTypeBase($className)) : + $this->getConstructorParameters($className); + + foreach ($originalParameters as $parameter) { $paramArray = [$parameter[0], $parameter[1], '']; if (isset($diConfiguration[$parameter[0]])) { - $paramArray[2] = $diConfiguration[$parameter[0]]['instance']; + $configuredParameter = $diConfiguration[$parameter[0]]; + if (is_array($configuredParameter)) { + if (isset($configuredParameter['instance'])) { + $paramArray[2] = $configuredParameter['instance']; + } else { + //TODO + } + } else { + $paramArray[2] = $configuredParameter; + } + } $result[] = $paramArray; } From 3d1ffabff03278cd9133e77b5e619a5bbd4d3893 Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Sun, 2 Apr 2017 07:01:01 -0700 Subject: [PATCH 37/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - added support for array type parameters --- .../Console/Command/DiInfoCommand.php | 12 +++++- .../Developer/Model/Di/Information.php | 37 +++++++++++++------ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php index 5762f825bd090..826cd41cc170d 100644 --- a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php +++ b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php @@ -79,8 +79,16 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln("Constructor Parameters:"); $paramsTable = new Table($output); $paramsTable - ->setHeaders(['Name', 'Type', 'Configured Type']); - $paramsTable->setRows([]); + ->setHeaders(['Name', 'Type', 'Configured Value']); + $parameters = $this->diInformation->getParameters($className); + $paramsTableArray = []; + foreach ($parameters as $parameterRow) { + if (is_array($parameterRow[2])) { + $parameterRow[2] = json_encode($parameterRow[2], JSON_PRETTY_PRINT); + } + $paramsTableArray[] = $parameterRow; + } + $paramsTable->setRows($paramsTableArray); $output->writeln($paramsTable->render()); $virtualTypes = $this->diInformation->getVirtualTypes($preference); diff --git a/app/code/Magento/Developer/Model/Di/Information.php b/app/code/Magento/Developer/Model/Di/Information.php index e826ca5f1f0b1..4c430d0a15d35 100644 --- a/app/code/Magento/Developer/Model/Di/Information.php +++ b/app/code/Magento/Developer/Model/Di/Information.php @@ -89,25 +89,38 @@ public function getParameters($className) $this->getConstructorParameters($className); foreach ($originalParameters as $parameter) { - $paramArray = [$parameter[0], $parameter[1], '']; + $paramArray = [$parameter[0], $parameter[1], is_array($parameter[3]) ? "" : $parameter[3]]; if (isset($diConfiguration[$parameter[0]])) { - $configuredParameter = $diConfiguration[$parameter[0]]; - if (is_array($configuredParameter)) { - if (isset($configuredParameter['instance'])) { - $paramArray[2] = $configuredParameter['instance']; - } else { - //TODO - } - } else { - $paramArray[2] = $configuredParameter; - } - + $paramArray[2] = $this->renderParameters($diConfiguration[$parameter[0]]); } $result[] = $paramArray; } return $result; } + /** + * Recursively retrieve array parameters + * + * @param $configuredParameter + * @return array|null + */ + private function renderParameters($configuredParameter) + { + $result = null; + if (is_array($configuredParameter)) { + if (isset($configuredParameter['instance'])) { + $result = $configuredParameter['instance']; + } else { + foreach ($configuredParameter as $keyName => $instance) { + $result[$keyName] = $this->renderParameters($instance); + } + } + } else { + $result = $configuredParameter; + } + return $result; + } + /** * Retrieve configured types of parameters of the constructor for the preference of the class * From e597209d067a03c6e5676b5e13300f896f9ba31a Mon Sep 17 00:00:00 2001 From: Oleksii Korshenko Date: Sun, 2 Apr 2017 11:06:36 -0700 Subject: [PATCH 38/65] MAGETWO-65353: [GitHub][PR] Fix product option files not copying to order dir. magento/magento2#8462 - fixed unit tests --- .../Model/Product/Option/Type/File.php | 25 +++++-- .../Model/Product/Option/Type/FileTest.php | 74 +++++++++++++++++-- 2 files changed, 84 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php index 3f783e439ca17..bbb739de874e8 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php @@ -32,9 +32,16 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType protected $_formattedOptionValue = null; /** - * @var \Magento\Framework\Filesystem\Directory\Write + * @var \Magento\Framework\Filesystem\Directory\ReadInterface + * @deprecated + * @see $mediaDirectory */ - protected $_mediaDirectory; + protected $_rootDirectory; + + /** + * @var \Magento\Framework\Filesystem\Directory\WriteInterface + */ + private $mediaDirectory; /** * Core file storage database @@ -114,7 +121,9 @@ public function __construct( $this->_escaper = $escaper; $this->_coreFileStorageDatabase = $coreFileStorageDatabase; $this->filesystem = $filesystem ?: \Magento\Framework\App\ObjectManager::getInstance()->get(Filesystem::class); - $this->_mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); + /** The _rootDirectory is deprecated. The field is initialized for backward compatibility */ + $this->_rootDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA); + $this->mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); $this->validatorInfo = $validatorInfo; $this->validatorFile = $validatorFile; $this->serializer = $serializer ? $serializer : ObjectManager::getInstance()->get(Json::class); @@ -473,17 +482,17 @@ public function copyQuoteToOrder() $quotePath = $value['quote_path']; $orderPath = $value['order_path']; - if (!$this->_mediaDirectory->isFile($quotePath) || !$this->_mediaDirectory->isReadable($quotePath)) { + if (!$this->mediaDirectory->isFile($quotePath) || !$this->mediaDirectory->isReadable($quotePath)) { throw new \Exception(); } - + if ($this->_coreFileStorageDatabase->checkDbUsage()) { $this->_coreFileStorageDatabase->copyFile( - $this->_mediaDirectory->getAbsolutePath($quotePath), - $this->_mediaDirectory->getAbsolutePath($orderPath) + $this->mediaDirectory->getAbsolutePath($quotePath), + $this->mediaDirectory->getAbsolutePath($orderPath) ); } else { - $this->_mediaDirectory->copyFile($quotePath, $orderPath); + $this->mediaDirectory->copyFile($quotePath, $orderPath); } } catch (\Exception $e) { return $this; diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php index 363b3789c2a62..5243302c97f67 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Type/FileTest.php @@ -83,7 +83,7 @@ protected function setUp() $this->coreFileStorageDatabase = $this->getMock( \Magento\MediaStorage\Helper\File\Storage\Database::class, - ['copyFile'], + ['copyFile', 'checkDbUsage'], [], '', false @@ -133,7 +133,7 @@ public function testGetCustomizedView() ); } - public function testCopyQuoteToOrder() + public function testCopyQuoteToOrderWithDbUsage() { $optionMock = $this->getMockBuilder(OptionInterface::class) ->disableOriginalConstructor() @@ -154,25 +154,29 @@ function ($value) { } ); - $optionMock->expects($this->any()) + $optionMock->expects($this->once()) ->method('getValue') ->will($this->returnValue($quoteValue)); - $this->mediaDirectory->expects($this->any()) + $this->mediaDirectory->expects($this->once()) ->method('isFile') ->with($this->equalTo($quotePath)) ->will($this->returnValue(true)); - $this->mediaDirectory->expects($this->any()) + $this->mediaDirectory->expects($this->once()) ->method('isReadable') ->with($this->equalTo($quotePath)) ->will($this->returnValue(true)); - $this->mediaDirectory->expects($this->any()) + $this->mediaDirectory->expects($this->exactly(2)) ->method('getAbsolutePath') ->will($this->returnValue('/file.path')); - $this->coreFileStorageDatabase->expects($this->any()) + $this->coreFileStorageDatabase->expects($this->once()) + ->method('checkDbUsage') + ->willReturn(true); + + $this->coreFileStorageDatabase->expects($this->once()) ->method('copyFile') ->will($this->returnValue('true')); @@ -185,6 +189,62 @@ function ($value) { ); } + public function testCopyQuoteToOrderWithoutUsage() + { + $optionMock = $this->getMockBuilder(OptionInterface::class) + ->disableOriginalConstructor() + ->setMethods(['getValue']) + ->getMockForAbstractClass(); + + $quotePath = '/quote/path/path/uploaded.file'; + $orderPath = '/order/path/path/uploaded.file'; + + $quoteValue = "{\"quote_path\":\"$quotePath\",\"order_path\":\"$orderPath\"}"; + + $this->serializer->expects($this->once()) + ->method('unserialize') + ->with($quoteValue) + ->willReturnCallback( + function ($value) { + return json_decode($value, true); + } + ); + + $optionMock->expects($this->once()) + ->method('getValue') + ->will($this->returnValue($quoteValue)); + + $this->mediaDirectory->expects($this->once()) + ->method('isFile') + ->with($this->equalTo($quotePath)) + ->will($this->returnValue(true)); + + $this->mediaDirectory->expects($this->once()) + ->method('isReadable') + ->with($this->equalTo($quotePath)) + ->will($this->returnValue(true)); + + $this->mediaDirectory->expects($this->never()) + ->method('getAbsolutePath') + ->will($this->returnValue('/file.path')); + + $this->coreFileStorageDatabase->expects($this->once()) + ->method('checkDbUsage') + ->willReturn(false); + + $this->coreFileStorageDatabase->expects($this->any()) + ->method('copyFile') + ->willReturn(false); + + $fileObject = $this->getFileObject(); + $fileObject->setData('configuration_item_option', $optionMock); + + $this->assertInstanceOf( + \Magento\Catalog\Model\Product\Option\Type\File::class, + $fileObject->copyQuoteToOrder() + ); + } + public function testGetFormattedOptionValue() { $resultValue = ['result']; From 63b14ad58f93fabf083be1281c55dbd4fecde45b Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Sun, 2 Apr 2017 13:16:21 -0700 Subject: [PATCH 39/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - added support for array type parameters --- .../Console/Command/DiInfoCommand.php | 104 +++++++++++------- .../Developer/Model/Di/Information.php | 17 +-- .../Magento/Developer/Model/Di/PluginList.php | 25 ++--- 3 files changed, 83 insertions(+), 63 deletions(-) diff --git a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php index 826cd41cc170d..c0833b89a8187 100644 --- a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php +++ b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php @@ -1,9 +1,7 @@ - * Date: 01/04/17 - * Time: 14.02 + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. */ namespace Magento\Developer\Console\Command; @@ -59,27 +57,33 @@ protected function configure() } /** - * {@inheritdoc} - * @throws \InvalidArgumentException + * Print Info on Class/Interface preference + * + * @param string $className + * @param OutputInterface $output + * @return void */ - protected function execute(InputInterface $input, OutputInterface $output) + private function printPreference($className, $output) { - $className = $input->getArgument(self::CLASS_NAME); - $output->writeln(''); - $output->writeln(sprintf('DI configuration for the class %s', $className)); - - $output->writeln( - sprintf('It is Virtual Type for the Class %s', $this->diInformation->getVirtualTypeBase($className)) - ); - $preference = $this->diInformation->getPreference($className); $output->writeln(''); $output->writeln(sprintf('Preference: %s', $preference)); $output->writeln(''); + } + + /** + * Print Info on Constructor Arguments + * + * @param string $className + * @param OutputInterface $output + * @return void + */ + private function printConstructorArguments($className, $output) + { $output->writeln("Constructor Parameters:"); $paramsTable = new Table($output); $paramsTable - ->setHeaders(['Name', 'Type', 'Configured Value']); + ->setHeaders(['Name', 'Requested Type', 'Configured Value']); $parameters = $this->diInformation->getParameters($className); $paramsTableArray = []; foreach ($parameters as $parameterRow) { @@ -90,8 +94,18 @@ protected function execute(InputInterface $input, OutputInterface $output) } $paramsTable->setRows($paramsTableArray); $output->writeln($paramsTable->render()); + } - $virtualTypes = $this->diInformation->getVirtualTypes($preference); + /** + * Print Info on Virtual Types + * + * @param string $className + * @param OutputInterface $output + * @return void + */ + private function printVirtualTypes($className, $output) + { + $virtualTypes = $this->diInformation->getVirtualTypes($className); if (!empty($virtualTypes)) { $output->writeln(''); $output->writeln("Virtual Types:"); @@ -99,14 +113,25 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(' ' . $virtualType); } } + } + /** + * Print Info on Plugins + * + * @param string $className + * @param OutputInterface $output + * @param string $label + * @return void + */ + private function printPlugins($className, $output, $label) + { $output->writeln(''); - $output->writeln("Plugins:"); + $output->writeln($label); $plugins = $this->diInformation->getPlugins($className); $parameters = []; foreach ($plugins as $type => $plugin) { - foreach ($plugin as $instance => $pluginMethods){ - foreach ($pluginMethods as $pluginMethod){ + foreach ($plugin as $instance => $pluginMethods) { + foreach ($pluginMethods as $pluginMethod) { $parameters[] = [$instance, $pluginMethod, $type]; } } @@ -114,30 +139,31 @@ protected function execute(InputInterface $input, OutputInterface $output) $table = new Table($output); $table - ->setHeaders(array('Plugin', 'Method', 'Type')) + ->setHeaders(['Plugin', 'Method', 'Type']) ->setRows($parameters); $output->writeln($table->render()); + } + /** + * {@inheritdoc} + * @throws \InvalidArgumentException + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $className = $input->getArgument(self::CLASS_NAME); $output->writeln(''); - $output->writeln("Preference Plugins:"); - $plugins = $this->diInformation->getPlugins($preference); - $parameters = []; - foreach ($plugins as $type => $plugin) { - foreach ($plugin as $instance => $pluginMethods){ - foreach ($pluginMethods as $pluginMethod){ - $parameters[] = [$instance, $pluginMethod, $type]; - } - } - } - - $table = new Table($output); - $table - ->setHeaders(array('Plugin', 'Method', 'Type')) - ->setRows($parameters); - - $output->writeln($table->render()); + $output->writeln(sprintf('DI configuration for the class %s', $className)); + $output->writeln( + sprintf('It is Virtual Type for the Class %s', $this->diInformation->getVirtualTypeBase($className)) + ); + $this->printPreference($className, $output); + $this->printConstructorArguments($className, $output); + $preference = $this->diInformation->getPreference($className); + $this->printVirtualTypes($preference, $output); + $this->printPlugins($className, $output, 'Plugins:'); + $this->printPlugins($preference, $output, 'Plugins for the Preference:'); return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } -} \ No newline at end of file +} diff --git a/app/code/Magento/Developer/Model/Di/Information.php b/app/code/Magento/Developer/Model/Di/Information.php index 4c430d0a15d35..003a32524d070 100644 --- a/app/code/Magento/Developer/Model/Di/Information.php +++ b/app/code/Magento/Developer/Model/Di/Information.php @@ -37,6 +37,7 @@ class Information /** * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig * @param \Magento\Framework\ObjectManager\DefinitionInterface $definitions + * @param \Magento\Developer\Model\Di\PluginList $pluginList */ public function __construct( \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, @@ -65,7 +66,7 @@ public function getPreference($className) /** * Retrieve parameters of the constructor for the preference of the class * - * @param $className + * @param string $className * @return array|null */ private function getConstructorParameters($className) @@ -77,7 +78,7 @@ private function getConstructorParameters($className) /** * Retrieve array of parameters for the class constructor * - * @param $className + * @param string $className * @return array */ public function getParameters($className) @@ -101,7 +102,7 @@ public function getParameters($className) /** * Recursively retrieve array parameters * - * @param $configuredParameter + * @param string $configuredParameter * @return array|null */ private function renderParameters($configuredParameter) @@ -109,14 +110,14 @@ private function renderParameters($configuredParameter) $result = null; if (is_array($configuredParameter)) { if (isset($configuredParameter['instance'])) { - $result = $configuredParameter['instance']; + $result = 'instance of ' . $configuredParameter['instance']; } else { foreach ($configuredParameter as $keyName => $instance) { $result[$keyName] = $this->renderParameters($instance); } } } else { - $result = $configuredParameter; + $result = 'string ' . $configuredParameter; } return $result; } @@ -124,7 +125,7 @@ private function renderParameters($configuredParameter) /** * Retrieve configured types of parameters of the constructor for the preference of the class * - * @param $className + * @param string $className * @return array|null */ private function getConfiguredConstructorParameters($className) @@ -135,7 +136,7 @@ private function getConfiguredConstructorParameters($className) /** * Retrieve virtual types for the class and the preference of the class * - * @param $className + * @param string $className * @return array */ public function getVirtualTypes($className) @@ -187,4 +188,4 @@ public function getVirtualTypeBase($className) } return false; } -} \ No newline at end of file +} diff --git a/app/code/Magento/Developer/Model/Di/PluginList.php b/app/code/Magento/Developer/Model/Di/PluginList.php index 7950cd0eac8ba..ea505bc97fd75 100644 --- a/app/code/Magento/Developer/Model/Di/PluginList.php +++ b/app/code/Magento/Developer/Model/Di/PluginList.php @@ -63,7 +63,7 @@ protected function isCurrentScope($scopeCode) /** * Load the plugins information * - * @param $type + * @param string $type * @return array */ private function getPlugins($type) @@ -79,42 +79,34 @@ private function getPlugins($type) /** * Return the list of plugins for the class * - * @param $className + * @param string $className * @return array * @throws \InvalidArgumentException */ public function getPluginsListByClass($className) { $this->getPlugins($className); - if(!isset($this->_inherited[$className])) + if (!isset($this->_inherited[$className])) { return $this->pluginList; + } + foreach ($this->_inherited[$className] as $pluginKey => $plugin) { foreach ($this->_definitions->getMethodList($plugin['instance']) as $pluginMethod => $methodTypes) { if ($methodTypes & DefinitionInterface::LISTENER_AROUND) { - if (!array_key_exists( - $plugin['instance'], - $this->pluginList['around']) - ) { + if (!array_key_exists($plugin['instance'], $this->pluginList['around'])) { $this->pluginList['around'][$plugin['instance']] = []; } $this->pluginList['around'][$plugin['instance']][] = $pluginMethod ; - } if ($methodTypes & DefinitionInterface::LISTENER_BEFORE) { - if (!array_key_exists( - $plugin['instance'], - $this->pluginList['before']) - ) { + if (!array_key_exists($plugin['instance'], $this->pluginList['before'])) { $this->pluginList['before'][$plugin['instance']] = []; } $this->pluginList['before'][$plugin['instance']][] = $pluginMethod ; } if ($methodTypes & DefinitionInterface::LISTENER_AFTER) { - if (!array_key_exists( - $plugin['instance'], - $this->pluginList['after']) - ) { + if (!array_key_exists($plugin['instance'], $this->pluginList['after'])) { $this->pluginList['after'][$plugin['instance']] = []; } $this->pluginList['after'][$plugin['instance']][] = $pluginMethod ; @@ -124,3 +116,4 @@ public function getPluginsListByClass($className) return $this->pluginList; } } + From 22120a261a755b5b63b2bc48d9aed8fcc057b4cd Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Sun, 2 Apr 2017 14:01:53 -0700 Subject: [PATCH 40/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - added unit test for Information class --- .../Developer/Model/Di/Information.php | 4 +- .../Test/Unit/Model/Di/InformationTest.php | 74 +++++++++++++++++++ 2 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 app/code/Magento/Developer/Test/Unit/Model/Di/InformationTest.php diff --git a/app/code/Magento/Developer/Model/Di/Information.php b/app/code/Magento/Developer/Model/Di/Information.php index 003a32524d070..0b122b41cd6d3 100644 --- a/app/code/Magento/Developer/Model/Di/Information.php +++ b/app/code/Magento/Developer/Model/Di/Information.php @@ -5,8 +5,6 @@ */ namespace Magento\Developer\Model\Di; -use Magento\Developer\Model\Di\PluginList; - class Information { /** @@ -87,7 +85,7 @@ public function getParameters($className) $diConfiguration = $this->getConfiguredConstructorParameters($className); $originalParameters = $this->isVirtualType($className) ? $this->getConstructorParameters($this->getVirtualTypeBase($className)) : - $this->getConstructorParameters($className); + $this->getConstructorParameters($this->getPreference($className)); foreach ($originalParameters as $parameter) { $paramArray = [$parameter[0], $parameter[1], is_array($parameter[3]) ? "" : $parameter[3]]; diff --git a/app/code/Magento/Developer/Test/Unit/Model/Di/InformationTest.php b/app/code/Magento/Developer/Test/Unit/Model/Di/InformationTest.php new file mode 100644 index 0000000000000..643a106cf9880 --- /dev/null +++ b/app/code/Magento/Developer/Test/Unit/Model/Di/InformationTest.php @@ -0,0 +1,74 @@ +objectManagerConfig = $this->getMockBuilder(ConfigInterface::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->definitions = $this->getMockBuilder(DefinitionInterface::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->pluginList = $this->getMockBuilder(PluginList::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->object = (new ObjectManager($this))->getObject(Information::class, [ + 'objectManagerConfig' => $this->objectManagerConfig, + 'definitions' => $this->definitions, + 'pluginList' => $this->pluginList, + ]); + } + + public function testGetPreference() + { + $this->objectManagerConfig->expects($this->any()) + ->method('getPreference') + ->with(Information::class) + ->willReturn(Information::class); + $this->assertEquals(Information::class, $this->object->getPreference(Information::class)); + } + + public function testGetParameters() + { + $this->objectManagerConfig->expects($this->any()) + ->method('getArguments') + ->with(Information::class) + ->willReturn(Information::class); + $this->assertEquals([], $this->object->getParameters(Information::class)); + } +} From 98bb812bd2f7eb8d5a0f777485b4cf76e594e47f Mon Sep 17 00:00:00 2001 From: Milan Osztromok Date: Mon, 3 Apr 2017 16:18:42 +0200 Subject: [PATCH 41/65] Show store view label (if defined) instead of default frontend label --- .../view/frontend/templates/product/view/attribute.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/attribute.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/attribute.phtml index d5730195b22b5..177b788f544ca 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/attribute.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/attribute.phtml @@ -23,7 +23,7 @@ $_attributeType = $block->getAtType(); $_attributeAddAttribute = $block->getAddAttribute(); if ($_attributeLabel && $_attributeLabel == 'default') { - $_attributeLabel = $_product->getResource()->getAttribute($_code)->getFrontendLabel(); + $_attributeLabel = $_product->getResource()->getAttribute($_code)->getStoreLabel(); } if ($_attributeType && $_attributeType == 'text') { $_attributeValue = ($_helper->productAttribute($_product, $_product->$_call(), $_code)) ? $_product->getAttributeText($_code) : ''; From 098b4978c66677789a11b10add07b30d664537de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Datt=C3=A9e?= Date: Tue, 20 Dec 2016 15:37:37 +0100 Subject: [PATCH 42/65] Updating trans_email resource name The resource name for trans_email resource is inconsistent with the resource declared in config module. Therefore enabling role to access the resource does not allow the role to access the menu --- app/code/Magento/Backend/etc/adminhtml/system.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Backend/etc/adminhtml/system.xml b/app/code/Magento/Backend/etc/adminhtml/system.xml index 7595846f4e530..ac4ba50d74be9 100644 --- a/app/code/Magento/Backend/etc/adminhtml/system.xml +++ b/app/code/Magento/Backend/etc/adminhtml/system.xml @@ -33,7 +33,7 @@ separator-top general - Magento_Backend::trans_email + Magento_Config::trans_email From d764c62f7a1575f4aa00e89bac010db7a4f97757 Mon Sep 17 00:00:00 2001 From: dadat Date: Tue, 20 Dec 2016 15:50:44 +0100 Subject: [PATCH 43/65] Roll back on other modification --- lib/internal/Magento/Framework/Translate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Translate.php b/lib/internal/Magento/Framework/Translate.php index 79fcdce2499ab..00805390fb8ba 100644 --- a/lib/internal/Magento/Framework/Translate.php +++ b/lib/internal/Magento/Framework/Translate.php @@ -182,8 +182,8 @@ public function loadData($area = null, $forceReload = false) $this->_data = []; $this->_loadModuleTranslation(); - $this->_loadPackTranslation(); $this->_loadThemeTranslation(); + $this->_loadPackTranslation(); $this->_loadDbTranslation(); if (!$forceReload) { From 097fcfa50eba0f3bfaebaeeee10659aca7d12e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Datt=C3=A9e?= Date: Tue, 4 Apr 2017 11:51:37 +0200 Subject: [PATCH 44/65] Rollback on other modification --- lib/internal/Magento/Framework/Translate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Translate.php b/lib/internal/Magento/Framework/Translate.php index 00805390fb8ba..79fcdce2499ab 100644 --- a/lib/internal/Magento/Framework/Translate.php +++ b/lib/internal/Magento/Framework/Translate.php @@ -182,8 +182,8 @@ public function loadData($area = null, $forceReload = false) $this->_data = []; $this->_loadModuleTranslation(); - $this->_loadThemeTranslation(); $this->_loadPackTranslation(); + $this->_loadThemeTranslation(); $this->_loadDbTranslation(); if (!$forceReload) { From 230276544b1874649d04f8f4df3c41e79eaa16d0 Mon Sep 17 00:00:00 2001 From: Scott Buchanan Date: Tue, 4 Apr 2017 14:49:52 -0400 Subject: [PATCH 45/65] fix to allow Zend_Db_Expr as default for column --- lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php index b066bb4db2912..25249b39703be 100644 --- a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php +++ b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php @@ -2422,7 +2422,7 @@ protected function _getColumnDefinition($options, $ddlType = null) * where default value can be quoted already. * We need to avoid "double-quoting" here */ - if ($cDefault !== null && strlen($cDefault)) { + if ($cDefault !== null && is_string($cDefault) && strlen($cDefault)) { $cDefault = str_replace("'", '', $cDefault); } From fad09271f6cc355a60e893fac01455a9162c80d7 Mon Sep 17 00:00:00 2001 From: Vova Yatsyuk Date: Fri, 7 Apr 2017 14:56:10 +0300 Subject: [PATCH 46/65] Improved text of exception message When some third-party module has syntax error inside its composer.json, it's very hard to determine which module caused an exception. This PR changes default message with the following: ``` Some_Module's composer.json error: Decoding failed: Syntax error ``` --- lib/internal/Magento/Framework/Module/PackageInfo.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Module/PackageInfo.php b/lib/internal/Magento/Framework/Module/PackageInfo.php index a6a34e227d996..5d52024457657 100644 --- a/lib/internal/Magento/Framework/Module/PackageInfo.php +++ b/lib/internal/Magento/Framework/Module/PackageInfo.php @@ -82,7 +82,15 @@ private function load() foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $moduleName => $moduleDir) { $key = $moduleDir . '/composer.json'; if (isset($jsonData[$key]) && $jsonData[$key]) { - $packageData = \Zend_Json::decode($jsonData[$key]); + try { + $packageData = \Zend_Json::decode($jsonData[$key]); + } catch (\Zend_Json_Exception $e) { + throw new \Zend_Json_Exception( + sprintf("%s's composer.json error: ", $moduleName) . + $e->getMessage() + ); + } + if (isset($packageData['name'])) { $this->packageModuleMap[$packageData['name']] = $moduleName; } From cbc9f39496ce6d3573b76c4136a37f75261696bf Mon Sep 17 00:00:00 2001 From: Vova Yatsyuk Date: Fri, 7 Apr 2017 22:59:24 +0300 Subject: [PATCH 47/65] Improved code readability - Original exception message moved into 'sprintf' arguments - "'s" suffix removed from module name --- lib/internal/Magento/Framework/Module/PackageInfo.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Module/PackageInfo.php b/lib/internal/Magento/Framework/Module/PackageInfo.php index 5d52024457657..bef401cb7911d 100644 --- a/lib/internal/Magento/Framework/Module/PackageInfo.php +++ b/lib/internal/Magento/Framework/Module/PackageInfo.php @@ -86,8 +86,11 @@ private function load() $packageData = \Zend_Json::decode($jsonData[$key]); } catch (\Zend_Json_Exception $e) { throw new \Zend_Json_Exception( - sprintf("%s's composer.json error: ", $moduleName) . - $e->getMessage() + sprintf( + "%s composer.json error: %s", + $moduleName, + $e->getMessage() + ) ); } From c22243e6559486c723eaa3686431ae12c076393f Mon Sep 17 00:00:00 2001 From: Vova Yatsyuk Date: Sat, 8 Apr 2017 00:25:22 +0300 Subject: [PATCH 48/65] Trailing spaces removed --- lib/internal/Magento/Framework/Module/PackageInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Module/PackageInfo.php b/lib/internal/Magento/Framework/Module/PackageInfo.php index bef401cb7911d..a80d234d43369 100644 --- a/lib/internal/Magento/Framework/Module/PackageInfo.php +++ b/lib/internal/Magento/Framework/Module/PackageInfo.php @@ -87,8 +87,8 @@ private function load() } catch (\Zend_Json_Exception $e) { throw new \Zend_Json_Exception( sprintf( - "%s composer.json error: %s", - $moduleName, + "%s composer.json error: %s", + $moduleName, $e->getMessage() ) ); From a9697890cdcfaf0b3d48fdcfadecce14b44d030a Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Tue, 11 Apr 2017 15:19:03 +0300 Subject: [PATCH 49/65] MAGETWO-67342: L3 Javascript job green when error present in log --- .../Bundle/view/base/web/js/price-bundle.js | 1 - .../Catalog/view/base/web/js/price-box.js | 2 +- .../Catalog/view/base/web/js/price-options.js | 1 - .../web/js/model/shipping-rates-validator.js | 2 +- .../web/js/model/shipping-rates-validator.js | 2 +- .../shipping-rates-validator/flatrate.js | 2 +- .../shipping-rates-validator/freeshipping.js | 2 +- .../shipping-rates-validator/tablerate.js | 2 +- .../view/frontend/web/js/page-cache.js | 4 +- .../Magento/Theme/view/frontend/web/menu.js | 2 +- .../view/base/web/js/core/renderer/layout.js | 2 +- .../base/web/js/form/components/button.js | 5 +- .../base/web/js/grid/columns/expandable.js | 13 +-- .../view/base/web/js/grid/columns/select.js | 12 +-- .../Ui/view/base/web/js/lib/core/events.js | 5 +- .../js/lib/knockout/extender/bound-nodes.js | 5 ++ .../web/js/lib/knockout/template/engine.js | 2 +- .../base/web/js/lib/logger/logger-utils.js | 10 +-- .../view/base/web/js/lib/registry/registry.js | 1 + .../Ui/view/base/web/js/lib/view/utils/raf.js | 1 + .../web/js/model/shipping-rates-validator.js | 2 +- .../web/js/model/shipping-rates-validator.js | 2 +- .../base/js/grid/columns/expandable.test.js | 1 + .../Ui/base/js/lib/logger/logger.test.js | 2 +- .../Ui/base/js/timeline/timeline.test.js | 1 + .../Test/Js/_files/eslint/.eslintrc-magento | 3 +- dev/tools/grunt/tasks/static.js | 6 +- lib/web/mage/adminhtml/grid.js | 6 +- .../mage/adminhtml/wysiwyg/tiny_mce/setup.js | 2 +- lib/web/mage/backend/suggest.js | 18 ++--- lib/web/mage/backend/tabs.js | 5 +- lib/web/mage/backend/tree-suggest.js | 1 - lib/web/mage/requirejs/baseUrlResolver.js | 81 ++++++++++--------- lib/web/mage/requirejs/text.js | 10 +-- lib/web/mage/view/composite.js | 4 +- lib/web/mage/zoom.js | 53 ++++++------ package.json.sample | 3 +- 37 files changed, 142 insertions(+), 134 deletions(-) diff --git a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js index f4ab9d0c3c7ed..b44b0e403cc90 100644 --- a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js +++ b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js @@ -239,7 +239,6 @@ define([ switch (optionType) { case 'radio': - case 'select-one': if (optionType === 'radio' && !element.is(':checked')) { diff --git a/app/code/Magento/Catalog/view/base/web/js/price-box.js b/app/code/Magento/Catalog/view/base/web/js/price-box.js index 20f42758bbbd0..cd72f5454b174 100644 --- a/app/code/Magento/Catalog/view/base/web/js/price-box.js +++ b/app/code/Magento/Catalog/view/base/web/js/price-box.js @@ -38,9 +38,9 @@ define([ * Widget creating. */ _create: function createPriceBox() { - this.cache = {}; var box = this.element; + this.cache = {}; this._setDefaultsFromPriceConfig(); this._setDefaultsFromDataSet(); diff --git a/app/code/Magento/Catalog/view/base/web/js/price-options.js b/app/code/Magento/Catalog/view/base/web/js/price-options.js index bde03db76e089..ceeea4c878622 100644 --- a/app/code/Magento/Catalog/view/base/web/js/price-options.js +++ b/app/code/Magento/Catalog/view/base/web/js/price-options.js @@ -43,7 +43,6 @@ define([ switch (optionType) { case 'text': - case 'textarea': changes[optionHash] = optionValue ? optionConfig.prices : {}; break; diff --git a/app/code/Magento/Dhl/view/frontend/web/js/model/shipping-rates-validator.js b/app/code/Magento/Dhl/view/frontend/web/js/model/shipping-rates-validator.js index 803a3879313c1..08b57f93841b4 100644 --- a/app/code/Magento/Dhl/view/frontend/web/js/model/shipping-rates-validator.js +++ b/app/code/Magento/Dhl/view/frontend/web/js/model/shipping-rates-validator.js @@ -32,7 +32,7 @@ define([ } }); - return !Boolean(this.validationErrors.length); + return !this.validationErrors.length; } }; }); diff --git a/app/code/Magento/Fedex/view/frontend/web/js/model/shipping-rates-validator.js b/app/code/Magento/Fedex/view/frontend/web/js/model/shipping-rates-validator.js index e06e10dc40c07..7178c2c4fc9dc 100644 --- a/app/code/Magento/Fedex/view/frontend/web/js/model/shipping-rates-validator.js +++ b/app/code/Magento/Fedex/view/frontend/web/js/model/shipping-rates-validator.js @@ -32,7 +32,7 @@ define([ } }); - return !Boolean(this.validationErrors.length); + return !this.validationErrors.length; } }; }); diff --git a/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/flatrate.js b/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/flatrate.js index 7036daa54e4f6..67a0d0aa2661e 100644 --- a/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/flatrate.js +++ b/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/flatrate.js @@ -31,7 +31,7 @@ define([ } }); - return !Boolean(this.validationErrors.length); + return !this.validationErrors.length; } }; }); diff --git a/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/freeshipping.js b/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/freeshipping.js index 6a06043607d87..627c729a9d17d 100644 --- a/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/freeshipping.js +++ b/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/freeshipping.js @@ -31,7 +31,7 @@ define([ } }); - return !Boolean(this.validationErrors.length); + return !this.validationErrors.length; } }; }); diff --git a/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/tablerate.js b/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/tablerate.js index a3a9ccaf5dbb3..d78f7be4d1500 100644 --- a/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/tablerate.js +++ b/app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/tablerate.js @@ -38,7 +38,7 @@ define([ } }); - return !Boolean(this.validationErrors.length); + return !this.validationErrors.length; } }; }); diff --git a/app/code/Magento/PageCache/view/frontend/web/js/page-cache.js b/app/code/Magento/PageCache/view/frontend/web/js/page-cache.js index fa58150e3e830..fccc8510ffc70 100644 --- a/app/code/Magento/PageCache/view/frontend/web/js/page-cache.js +++ b/app/code/Magento/PageCache/view/frontend/web/js/page-cache.js @@ -41,9 +41,11 @@ define([ * @param {jQuery} element - Comment holder */ (function lookup(element) { + var iframeHostName; + // prevent cross origin iframe content reading if ($(element).prop('tagName') === 'IFRAME') { - var iframeHostName = $('').prop('href', $(element).prop('src')) + iframeHostName = $('').prop('href', $(element).prop('src')) .prop('hostname'); if (window.location.hostname !== iframeHostName) { diff --git a/app/code/Magento/Theme/view/frontend/web/menu.js b/app/code/Magento/Theme/view/frontend/web/menu.js index aa13826bb6e87..677de6a241c7e 100644 --- a/app/code/Magento/Theme/view/frontend/web/menu.js +++ b/app/code/Magento/Theme/view/frontend/web/menu.js @@ -157,7 +157,7 @@ define([ //mainNav(); //run navigation with delays - mainNav('nav', { + window.mainNav('nav', { 'show_delay': '100', 'hide_delay': '100' }); diff --git a/app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js b/app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js index a5a74e2fa2861..fe312738469e7 100644 --- a/app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js +++ b/app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js @@ -118,7 +118,7 @@ define([ component: node.component }); loaded.resolve(node, constr); - }, function (err) { + }, function () { consoleLogger.error('componentLoadingFail', { component: node.component }); diff --git a/app/code/Magento/Ui/view/base/web/js/form/components/button.js b/app/code/Magento/Ui/view/base/web/js/form/components/button.js index e66a60e89492f..df85af5824d92 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/components/button.js +++ b/app/code/Magento/Ui/view/base/web/js/form/components/button.js @@ -10,8 +10,9 @@ define([ 'uiElement', 'uiRegistry', 'uiLayout', - 'mageUtils' -], function (Element, registry, layout, utils) { + 'mageUtils', + 'underscore' +], function (Element, registry, layout, utils, _) { 'use strict'; return Element.extend({ diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/expandable.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/expandable.js index 0874a9d32c8e9..8bbe5971490a7 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/expandable.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/expandable.js @@ -3,8 +3,9 @@ * See COPYING.txt for license details. */ define([ - './column' -], function (Column) { + './column', + 'underscore' +], function (Column, _) { 'use strict'; return Column.extend({ @@ -78,14 +79,14 @@ define([ flatOptions: function (options) { var self = this; - return options.reduce(function (options, option) { + return options.reduce(function (opts, option) { if (_.isArray(option.value)) { - options = options.concat(self.flatOptions(option.value)); + opts = opts.concat(self.flatOptions(option.value)); } else { - options.push(option); + opts.push(option); } - return options; + return opts; }, []); }, diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js index 162acef3b033b..20c885ba964f9 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/select.js @@ -13,8 +13,6 @@ define([ 'use strict'; return Column.extend({ - - /*eslint-disable eqeqeq*/ /** * Retrieves label associated with a provided value. * @@ -57,17 +55,15 @@ define([ flatOptions: function (options) { var self = this; - return options.reduce(function (options, option) { + return options.reduce(function (opts, option) { if (_.isArray(option.value)) { - options = options.concat(self.flatOptions(option.value)); + opts = opts.concat(self.flatOptions(option.value)); } else { - options.push(option); + opts.push(option); } - return options; + return opts; }, []); } - - /*eslint-enable eqeqeq*/ }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/lib/core/events.js b/app/code/Magento/Ui/view/base/web/js/lib/core/events.js index 097cf1552439a..fdb11cd89f361 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/core/events.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/core/events.js @@ -2,6 +2,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + +/* global WeakMap, Map*/ define([ 'ko', 'underscore', @@ -34,7 +36,7 @@ define([ * * @param {Object} obj - Key in the events weakmap. * @param {String} ns - Callback namespace. - * @param {Fucntion} callback - Event callback. + * @param {Function} callback - Event callback. * @param {String} name - Name of the event. */ function addHandler(obj, ns, callback, name) { @@ -96,6 +98,7 @@ define([ * Calls callback when name event is triggered. * @param {String} events * @param {Function} callback + * @param {Function} ns * @return {Object} reference to this */ on: function (events, callback, ns) { diff --git a/app/code/Magento/Ui/view/base/web/js/lib/knockout/extender/bound-nodes.js b/app/code/Magento/Ui/view/base/web/js/lib/knockout/extender/bound-nodes.js index 5ecb1930dcaed..a332b595bdf3c 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/knockout/extender/bound-nodes.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/knockout/extender/bound-nodes.js @@ -3,6 +3,7 @@ * See COPYING.txt for license details. */ +/* global WeakMap */ define([ 'ko', 'underscore', @@ -87,6 +88,7 @@ define([ * Returns node's first sibling of 'element' type within the common component scope * * @param {HTMLElement} node + * @param {*} data * @returns {HTMLElement} */ function getElement(node, data) { @@ -111,6 +113,8 @@ define([ * to track nodes associated with model. * * @param {Function} orig - Original 'applyBindings' method. + * @param {Object} ctx + * @param {HTMLElement} node - Original 'applyBindings' method. */ applyBindings: function (orig, ctx, node) { var result = orig(), @@ -136,6 +140,7 @@ define([ * to track nodes associated with model. * * @param {Function} orig - Original 'cleanNode' method. + * @param {HTMLElement} node - Original 'cleanNode' method. */ cleanNode: function (orig, node) { var result = orig(), diff --git a/app/code/Magento/Ui/view/base/web/js/lib/knockout/template/engine.js b/app/code/Magento/Ui/view/base/web/js/lib/knockout/template/engine.js index 546c6c913707f..b1f5eeff6fb63 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/knockout/template/engine.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/knockout/template/engine.js @@ -66,7 +66,7 @@ define([ component: bindingContext.$data.name }); source.nodes(rendered); - }).fail(function (err) { + }).fail(function () { consoleLogger.error('templateLoadingFail', { template: templateId, component: bindingContext.$data.name diff --git a/app/code/Magento/Ui/view/base/web/js/lib/logger/logger-utils.js b/app/code/Magento/Ui/view/base/web/js/lib/logger/logger-utils.js index 194fc9501ed60..a6c7590ded663 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/logger/logger-utils.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/logger/logger-utils.js @@ -34,11 +34,11 @@ define([], function () { promise.state() === 'pending' ? this.logger[levels.failed](messages.failed, config.data) : this.logger[levels.loaded](messages.loaded, config.data); - }.bind(this), wait) + }.bind(this), wait); }; /** - * Method that creats object of messages + * Method that creates object of messages * @param {String} requested - log message that showing that request for class is started * @param {String} loaded - log message that show when requested class is loaded * @param {String} failded - log message that show when requested class is failed @@ -49,11 +49,11 @@ define([], function () { requested: requested || '', loaded: loaded || '', failed: failded || '' - } + }; }; /** - * Method that creats object of log levels + * Method that creates object of log levels * @param {String} requested - log message that showing that request for class is started * @param {String} loaded - log message that show when requested class is loaded * @param {String} failded - log message that show when requested class is failed @@ -64,7 +64,7 @@ define([], function () { requested: requested || 'info', loaded: loaded || 'info', failed: failded || 'warn' - } + }; }; return LogUtils; diff --git a/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js b/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js index 5d97c50c3ff72..5c3c71e31823d 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js @@ -6,6 +6,7 @@ /** * @api */ +/* global WeakMap */ define([ 'jquery', 'underscore', diff --git a/app/code/Magento/Ui/view/base/web/js/lib/view/utils/raf.js b/app/code/Magento/Ui/view/base/web/js/lib/view/utils/raf.js index 2156def5048d5..1cbbfb3ecee48 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/view/utils/raf.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/view/utils/raf.js @@ -3,6 +3,7 @@ * See COPYING.txt for license details. */ +/* global WeakMap */ define([ 'es6-collections' ], function () { diff --git a/app/code/Magento/Ups/view/frontend/web/js/model/shipping-rates-validator.js b/app/code/Magento/Ups/view/frontend/web/js/model/shipping-rates-validator.js index 8eb74492fc98e..f3029b4f6c37e 100644 --- a/app/code/Magento/Ups/view/frontend/web/js/model/shipping-rates-validator.js +++ b/app/code/Magento/Ups/view/frontend/web/js/model/shipping-rates-validator.js @@ -31,7 +31,7 @@ define([ } }); - return !Boolean(this.validationErrors.length); + return !this.validationErrors.length; } }; }); diff --git a/app/code/Magento/Usps/view/frontend/web/js/model/shipping-rates-validator.js b/app/code/Magento/Usps/view/frontend/web/js/model/shipping-rates-validator.js index 2365127e62a7a..6be63e5e5c2a1 100644 --- a/app/code/Magento/Usps/view/frontend/web/js/model/shipping-rates-validator.js +++ b/app/code/Magento/Usps/view/frontend/web/js/model/shipping-rates-validator.js @@ -33,7 +33,7 @@ define([ } }); - if (!Boolean(this.validationErrors.length)) { + if (!this.validationErrors.length) { if (address['country_id'] == checkoutConfig.originCountryCode) { //eslint-disable-line eqeqeq return !utils.isEmpty(address.postcode); } diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/expandable.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/expandable.test.js index 2683d624ae6e7..1c3b51919f5f3 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/expandable.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/expandable.test.js @@ -3,6 +3,7 @@ * See COPYING.txt for license details. */ +/* eslint-disable max-nested-callbacks */ define([ 'Magento_Ui/js/grid/columns/expandable' ], function (Expandable) { diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/logger/logger.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/logger/logger.test.js index 65051c4c72600..5028c254e49b0 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/logger/logger.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/logger/logger.test.js @@ -138,7 +138,7 @@ define([ it('removes previously applied filter criteria', function () { var logger = createLogger(), criteria = function () { - return false + return false; }; spyOn(entryHandler, 'show'); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/timeline/timeline.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/timeline/timeline.test.js index 204e79c8451cd..df125fbb45b9e 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/timeline/timeline.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/timeline/timeline.test.js @@ -3,6 +3,7 @@ * See COPYING.txt for license details. */ +/* eslint-disable max-nested-callbacks */ define([ 'Magento_Ui/js/timeline/timeline' ], function (Timeline) { diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento b/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento index 6dd7d08063121..3e9844189a942 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento @@ -8,7 +8,6 @@ "node": true }, "rules": { - "consistent-return": 2, "eqeqeq": [2, "smart"], "guard-for-in": 2, "lines-around-comment": [ @@ -74,7 +73,7 @@ "radix": 2, "semi": [2, "always"], "semi-spacing": 2, - "strict": 2, + "strict": ["error", "function"], "use-isnan": 2, "valid-typeof": 2, "vars-on-top": 2 diff --git a/dev/tools/grunt/tasks/static.js b/dev/tools/grunt/tasks/static.js index 7d54c199ecd3a..22ae25673d214 100644 --- a/dev/tools/grunt/tasks/static.js +++ b/dev/tools/grunt/tasks/static.js @@ -20,13 +20,15 @@ module.exports = function (grunt) { var currentTarget = target || 'test', file = grunt.option('file'), tasks = [ + 'continue:on', 'eslint:' + currentTarget, - 'jscs:' + currentTarget + 'jscs:' + currentTarget, + 'continue:off', + 'continue:fail-on-warning' ]; setConfig('eslint', currentTarget, cvf.getFiles(file)); setConfig('jscs', currentTarget, cvf.getFiles(file)); - grunt.option('force', true); grunt.task.run(tasks); if (!grunt.option('file')) { diff --git a/lib/web/mage/adminhtml/grid.js b/lib/web/mage/adminhtml/grid.js index 8ffb5550726fa..c9af869d79161 100644 --- a/lib/web/mage/adminhtml/grid.js +++ b/lib/web/mage/adminhtml/grid.js @@ -841,7 +841,7 @@ define([ if (element.isMassactionCheckbox) { checkbox = element; //eslint-disable-line no-undef } - }.bind(this)); + }); return checkbox; //eslint-disable-line no-undef }, @@ -852,7 +852,7 @@ define([ initCheckboxes: function () { this.getCheckboxes().each(function (checkbox) { //eslint-disable-line no-extra-bind checkbox.isMassactionCheckbox = true; //eslint-disable-line no-undef - }.bind(this)); + }); }, /** @@ -954,7 +954,7 @@ define([ this.getCheckboxes().each(function (checkbox) { //eslint-disable-line no-extra-bind result.push(checkbox.value); - }.bind(this)); + }); return result; }, diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js index d4b0cddd0f708..aa0b19f5f11a2 100755 --- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js +++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js @@ -467,7 +467,7 @@ define([ return content.gsub(reg, function (match) { //eslint-disable-line no-extra-bind return Base64.mageDecode(match[1]); - }.bind(this)); + }); }, /** diff --git a/lib/web/mage/backend/suggest.js b/lib/web/mage/backend/suggest.js index 5947e1e25fde1..81bde35f9e12a 100644 --- a/lib/web/mage/backend/suggest.js +++ b/lib/web/mage/backend/suggest.js @@ -349,17 +349,17 @@ $.each(this._control.eventsMap, $.proxy(function (suggestEvent, controlEvents) { $.each(controlEvents, $.proxy(function (i, handlerName) { switch (suggestEvent) { - case 'select': - events[handlerName] = this._onSelectItem; - break; + case 'select': + events[handlerName] = this._onSelectItem; + break; - case 'focus': - events[handlerName] = this._focusItem; - break; + case 'focus': + events[handlerName] = this._focusItem; + break; - case 'blur': - events[handlerName] = this._blurItem; - break; + case 'blur': + events[handlerName] = this._blurItem; + break; } }, this)); }, this)); diff --git a/lib/web/mage/backend/tabs.js b/lib/web/mage/backend/tabs.js index 9dd362370948c..5a705ca00e1ec 100644 --- a/lib/web/mage/backend/tabs.js +++ b/lib/web/mage/backend/tabs.js @@ -366,11 +366,9 @@ /** * Add active tab id in data object when "beforeSubmit" event is triggered - * @param {Object} e - event object - * @param {Object} data - event data object * @protected */ - _onBeforeSubmit: function (e, data) { + _onBeforeSubmit: function () { var activeAnchor = this.activeAnchor(), activeTabId = activeAnchor.prop('id'), options; @@ -387,7 +385,6 @@ } }; options.action.args[this.options.tabIdArgument] = activeTabId; - data = data ? $.extend(data, options) : options; } }); diff --git a/lib/web/mage/backend/tree-suggest.js b/lib/web/mage/backend/tree-suggest.js index 4c6ba4e6c882c..47f034b0b2431 100644 --- a/lib/web/mage/backend/tree-suggest.js +++ b/lib/web/mage/backend/tree-suggest.js @@ -178,7 +178,6 @@ switch (event.keyCode) { case keyCode.LEFT: - case keyCode.RIGHT: if (this.isDropdownShown()) { diff --git a/lib/web/mage/requirejs/baseUrlResolver.js b/lib/web/mage/requirejs/baseUrlResolver.js index 1eef12f861faf..693006bf5f692 100644 --- a/lib/web/mage/requirejs/baseUrlResolver.js +++ b/lib/web/mage/requirejs/baseUrlResolver.js @@ -14,6 +14,9 @@ } }); */ + +/* global jsSuffixRegExp */ +/* eslint-disable max-depth */ define('baseUrlInterceptor', [ 'module' ], function (module) { @@ -23,6 +26,7 @@ define('baseUrlInterceptor', [ * RequireJS Context object */ var ctx = require.s.contexts._, + /** * Original function * @@ -37,6 +41,37 @@ define('baseUrlInterceptor', [ */ newContextConstr = require.s.newContext; + /** + * Remove dots from URL + * + * @param {Array} ary + */ + function trimDots(ary) { + var i, part, length = ary.length; + + for (i = 0; i < length; i++) { + part = ary[i]; + + if (part === '.') { + ary.splice(i, 1); + i -= 1; + } else if (part === '..') { + if (i === 1 && (ary[2] === '..' || ary[0] === '..')) { + //End of the line. Keep at least one non-dot + //path segment at the front so it can be mapped + //correctly to disk. Otherwise, there is likely + //no path mapping for a path starting with '..'. + //This can still fail, but catches the most reasonable + //uses of .. + break; + } else if (i > 0) { + ary.splice(i - 1, 2); + i -= 2; + } + } + } + } + /** * Normalize URL string (remove '/../') * @@ -47,8 +82,7 @@ define('baseUrlInterceptor', [ * @returns {*} */ function normalize(name, baseName, applyMap, localContext) { - var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex, - foundMap, foundI, foundStarMap, starI, + var lastIndex, baseParts = baseName && baseName.split('/'), normalizedBaseParts = baseParts; @@ -88,47 +122,16 @@ define('baseUrlInterceptor', [ return name; } - /** - * Remove dots from URL - * - * @param {Array} ary - */ - function trimDots(ary) { - var i, part, length = ary.length; - - for (i = 0; i < length; i++) { - part = ary[i]; - - if (part === '.') { - ary.splice(i, 1); - i -= 1; - } else if (part === '..') { - if (i === 1 && (ary[2] === '..' || ary[0] === '..')) { - //End of the line. Keep at least one non-dot - //path segment at the front so it can be mapped - //correctly to disk. Otherwise, there is likely - //no path mapping for a path starting with '..'. - //This can still fail, but catches the most reasonable - //uses of .. - break; - } else if (i > 0) { - ary.splice(i - 1, 2); - i -= 2; - } - } - } - } - /** * Get full url. * - * @param {Object} ctx + * @param {Object} context * @param {String} url * @return {String} */ - function getUrl(ctx, url) { - var baseUrl = ctx.config.baseUrl, - newConfig = ctx.config, + function getUrl(context, url) { + var baseUrl = context.config.baseUrl, + newConfig = context.config, modulePath = url.replace(baseUrl, ''), newBaseUrl, rewrite = module.config()[modulePath]; @@ -166,11 +169,11 @@ define('baseUrlInterceptor', [ * @returns {String} */ newCtx.nameToUrl = function () { - return getUrl(newCtx, newOrigNameToUrl.apply(newCtx, arguments)) + return getUrl(newCtx, newOrigNameToUrl.apply(newCtx, arguments)); }; return newCtx; - } + }; }); require(['baseUrlInterceptor'], function () { diff --git a/lib/web/mage/requirejs/text.js b/lib/web/mage/requirejs/text.js index 1eb8d0fb1660d..74bc896890e74 100644 --- a/lib/web/mage/requirejs/text.js +++ b/lib/web/mage/requirejs/text.js @@ -86,8 +86,7 @@ define(['module'], function (module) { */ function getContent(url, callback, fail, headers) { var xhr = createRequest(url), - header, - errorHandler = fail || Function(); + header; xhr.open('GET', url); @@ -101,12 +100,11 @@ define(['module'], function (module) { } /** - * @override - * - * @param {Event} evt + * @inheritdoc */ - xhr.onreadystatechange = function (evt) { + xhr.onreadystatechange = function () { var status, err; + //Do not explicitly handle errors, those should be //visible via console output in the browser. if (xhr.readyState === 4) { diff --git a/lib/web/mage/view/composite.js b/lib/web/mage/view/composite.js index a9ee731075c78..245bfa1507c6a 100644 --- a/lib/web/mage/view/composite.js +++ b/lib/web/mage/view/composite.js @@ -5,12 +5,10 @@ /* eslint-disable strict */ define(['jquery'], function ($) { - return function (wrapperTag) { + return function () { var renderedChildren = {}, children = {}; - wrapperTag = wrapperTag || 'div'; - return { /** * @param {*} child diff --git a/lib/web/mage/zoom.js b/lib/web/mage/zoom.js index 4008c089d5313..d0d90df3eb2e5 100644 --- a/lib/web/mage/zoom.js +++ b/lib/web/mage/zoom.js @@ -181,34 +181,35 @@ }; switch (control) { - case 'display': - position = { - my: 'left+' + this.options.controls.display.left + ' top+' + this.options.controls.display.top + '', - at: 'left+' + $(this.image).outerWidth() + ' top', - of: $(this.image) - }; - break; + case 'display': + position = { + my: 'left+' + this.options.controls.display.left + ' top+' + + this.options.controls.display.top + '', + at: 'left+' + $(this.image).outerWidth() + ' top', + of: $(this.image) + }; + break; - case 'track': - $.extend(css, { - height: $(this.image).height(), - width: $(this.image).width() - }); - position = { - my: 'left top', - at: 'left top', - of: $(this.image) - }; - break; + case 'track': + $.extend(css, { + height: $(this.image).height(), + width: $(this.image).width() + }); + position = { + my: 'left top', + at: 'left top', + of: $(this.image) + }; + break; - case 'lens': - $.extend(css, this._calculateLensSize(), { - background: controlData.background, - opacity: controlData.opacity, - left: 0, - top: 0 - }); - break; + case 'lens': + $.extend(css, this._calculateLensSize(), { + background: controlData.background, + opacity: controlData.opacity, + left: 0, + top: 0 + }); + break; } this[control].css(css); diff --git a/package.json.sample b/package.json.sample index a88a4ad6bab8c..5460411f7e8e8 100644 --- a/package.json.sample +++ b/package.json.sample @@ -13,6 +13,7 @@ "grunt": "^0.4.5", "grunt-autoprefixer": "^2.0.0", "grunt-banner": "^0.4.0", + "grunt-continue": "~0.1.0", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-connect": "^0.9.0", "grunt-contrib-cssmin": "^0.10.0", @@ -20,7 +21,7 @@ "grunt-contrib-jasmine": "^1.0.0", "grunt-contrib-less": "^0.12.0", "grunt-contrib-watch": "^0.6.1", - "grunt-eslint": "17.3.1", + "grunt-eslint": "~19.0.0", "grunt-exec": "^0.4.6", "grunt-jscs": "2.2.0", "grunt-replace": "^0.9.2", From 2d0365611a14087825148e68ede1818c4102ff50 Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Tue, 11 Apr 2017 20:37:35 -0500 Subject: [PATCH 50/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - fixed the virtual types message - added information about the area --- .../Developer/Console/Command/DiInfoCommand.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php index c0833b89a8187..79fcae74cf2c1 100644 --- a/app/code/Magento/Developer/Console/Command/DiInfoCommand.php +++ b/app/code/Magento/Developer/Console/Command/DiInfoCommand.php @@ -152,11 +152,15 @@ private function printPlugins($className, $output, $label) protected function execute(InputInterface $input, OutputInterface $output) { $className = $input->getArgument(self::CLASS_NAME); + $output->setDecorated(true); $output->writeln(''); - $output->writeln(sprintf('DI configuration for the class %s', $className)); - $output->writeln( - sprintf('It is Virtual Type for the Class %s', $this->diInformation->getVirtualTypeBase($className)) - ); + $output->writeln(sprintf('DI configuration for the class %s in the GLOBAL area', $className)); + + if ($this->diInformation->isVirtualType($className)) { + $output->writeln( + sprintf('It is Virtual Type for the Class %s', $this->diInformation->getVirtualTypeBase($className)) + ); + } $this->printPreference($className, $output); $this->printConstructorArguments($className, $output); $preference = $this->diInformation->getPreference($className); From 3b4f21f56ddd2cd13da505b2d940603006618d20 Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Tue, 11 Apr 2017 20:57:20 -0500 Subject: [PATCH 51/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - fixed unit test --- .../Developer/Test/Unit/Model/Di/InformationTest.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Developer/Test/Unit/Model/Di/InformationTest.php b/app/code/Magento/Developer/Test/Unit/Model/Di/InformationTest.php index 643a106cf9880..35fefce8834cc 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/Di/InformationTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/Di/InformationTest.php @@ -65,10 +65,17 @@ public function testGetPreference() public function testGetParameters() { + $this->definitions->expects($this->any()) + ->method('getParameters') + ->with(Information::class) + ->willReturn([['information', Information::class, false, null]]); $this->objectManagerConfig->expects($this->any()) - ->method('getArguments') + ->method('getPreference') ->with(Information::class) ->willReturn(Information::class); - $this->assertEquals([], $this->object->getParameters(Information::class)); + $this->assertEquals( + [['information', Information::class, null]], + $this->object->getParameters(Information::class) + ); } } From fd9321c519ba9ca3d7d58fba4faf1bef54d448eb Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Tue, 11 Apr 2017 21:53:22 -0500 Subject: [PATCH 52/65] magento-hackathon/Imagine2017#11: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - fixed issue with the empty constructor parameters list - fixed static test --- .../Developer/Model/Di/Information.php | 4 ++ .../Magento/Developer/Model/Di/PluginList.php | 72 ++++++++++++------- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/app/code/Magento/Developer/Model/Di/Information.php b/app/code/Magento/Developer/Model/Di/Information.php index 0b122b41cd6d3..37d609fa17c7e 100644 --- a/app/code/Magento/Developer/Model/Di/Information.php +++ b/app/code/Magento/Developer/Model/Di/Information.php @@ -87,6 +87,10 @@ public function getParameters($className) $this->getConstructorParameters($this->getVirtualTypeBase($className)) : $this->getConstructorParameters($this->getPreference($className)); + if (!$originalParameters) { + return $result; + } + foreach ($originalParameters as $parameter) { $paramArray = [$parameter[0], $parameter[1], is_array($parameter[3]) ? "" : $parameter[3]]; if (isset($diConfiguration[$parameter[0]])) { diff --git a/app/code/Magento/Developer/Model/Di/PluginList.php b/app/code/Magento/Developer/Model/Di/PluginList.php index ea505bc97fd75..12bd661414efb 100644 --- a/app/code/Magento/Developer/Model/Di/PluginList.php +++ b/app/code/Magento/Developer/Model/Di/PluginList.php @@ -14,13 +14,31 @@ */ class PluginList extends Interception\PluginList\PluginList { + /**#@+ + * Constants for the plugin types + */ + const PLUGIN_TYPE_BEFORE = 'before'; + const PLUGIN_TYPE_AROUND = 'around'; + const PLUGIN_TYPE_AFTER = 'after'; + /**#@-*/ + /** * @var array */ private $pluginList = [ - 'before' => [], - 'around' => [], - 'after' => [] + self::PLUGIN_TYPE_BEFORE => [], + self::PLUGIN_TYPE_AROUND => [], + self::PLUGIN_TYPE_AFTER => [] + ]; + + /** + * Mapping of plugin type codes to plugin types + * @var array + */ + private $pluginTypeMapping = [ + DefinitionInterface::LISTENER_AROUND => self::PLUGIN_TYPE_AROUND, + DefinitionInterface::LISTENER_BEFORE => self::PLUGIN_TYPE_BEFORE, + DefinitionInterface::LISTENER_AFTER => self::PLUGIN_TYPE_AFTER ]; /** @@ -75,7 +93,6 @@ private function getPlugins($type) return $this->_inherited[$type]; } - /** * Return the list of plugins for the class * @@ -92,28 +109,35 @@ public function getPluginsListByClass($className) foreach ($this->_inherited[$className] as $pluginKey => $plugin) { foreach ($this->_definitions->getMethodList($plugin['instance']) as $pluginMethod => $methodTypes) { - if ($methodTypes & DefinitionInterface::LISTENER_AROUND) { - if (!array_key_exists($plugin['instance'], $this->pluginList['around'])) { - $this->pluginList['around'][$plugin['instance']] = []; - } - $this->pluginList['around'][$plugin['instance']][] = $pluginMethod ; - } - if ($methodTypes & DefinitionInterface::LISTENER_BEFORE) { - if (!array_key_exists($plugin['instance'], $this->pluginList['before'])) { - $this->pluginList['before'][$plugin['instance']] = []; - } - $this->pluginList['before'][$plugin['instance']][] = $pluginMethod ; - - } - if ($methodTypes & DefinitionInterface::LISTENER_AFTER) { - if (!array_key_exists($plugin['instance'], $this->pluginList['after'])) { - $this->pluginList['after'][$plugin['instance']] = []; - } - $this->pluginList['after'][$plugin['instance']][] = $pluginMethod ; - } + $this->addPluginToList($plugin['instance'], $pluginMethod, $methodTypes, + DefinitionInterface::LISTENER_AROUND + ); + $this->addPluginToList($plugin['instance'], $pluginMethod, $methodTypes, + DefinitionInterface::LISTENER_BEFORE + ); + $this->addPluginToList($plugin['instance'], $pluginMethod, $methodTypes, + DefinitionInterface::LISTENER_AFTER + ); } } return $this->pluginList; } -} + /** + * Add plugin to the appropriate type bucket + * + * @param string $pluginInstance + * @param string $pluginMethod + * @param int $methodTypes + * @param int $typeCode + */ + private function addPluginToList($pluginInstance, $pluginMethod, $methodTypes, $typeCode) + { + if ($methodTypes & $typeCode) { + if (!array_key_exists($pluginInstance, $this->pluginList[$this->pluginTypeMapping[$typeCode]])) { + $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance] = []; + } + $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance][] = $pluginMethod ; + } + } +} From 2552aa2fab9082e67ad8a843fe502488bc20d6be Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Tue, 11 Apr 2017 22:32:10 -0500 Subject: [PATCH 53/65] Fixed MAGETWO-67411: Add label coding information to README - added labels color coding to the README file --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 020f20ff70b43..f678684003a30 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,20 @@ To suggest documentation improvements, click [here][4]. [3]: [4]: +

Labels applied by the Magento team

+ +| Label | Description | +| ------------- |-------------| +| ![DOC](http://devdocs.magento.com/common/images/github_DOC.png) | Affects Documentation domain. | +| ![PROD](http://devdocs.magento.com/common/images/github_PROD.png) | Affects the Product team (mostly feature requests or business logic change). | +| ![TECH](http://devdocs.magento.com/common/images/github_TECH.png) | Affects Architect Group (mostly to make decisions around technology changes). | +| ![accept](http://devdocs.magento.com/common/images/github_accept.png) | The pull request has been accepted and will be merged into mainline code. | +| ![reject](http://devdocs.magento.com/common/images/github_reject.png) | The pull request has been rejected and will not be merged into mainline code. Possible reasons can include but are not limited to: issue has already been fixed in another code contribution, or there is an issue with the code contribution. | +| ![bug report](http://devdocs.magento.com/common/images/github_bug.png) | The Magento Team has confirmed that this issue contains the minimum required information to reproduce. | +| ![acknowledged](http://devdocs.magento.com/common/images/gitHub_acknowledged.png) | The Magento Team has validated the issue and an internal ticket has been created. | +| ![acknowledged](http://devdocs.magento.com/common/images/github_inProgress.png) | The internal ticket is currently in progress, fix is scheduled to be delivered. | +| ![acknowledged](http://devdocs.magento.com/common/images/github_needsUpdate.png) | The Magento Team needs additional information from the reporter to properly prioritize and process the issue or pull request. | +

Reporting security issues

To report security vulnerabilities in Magento software or web sites, please e-mail
security@magento.com. Please do not report security issues using GitHub. Be sure to encrypt your e-mail with our encryption key if it includes sensitive information. Learn more about reporting security issues here. From c5a6529ae5ed837b9f788017c01d3aba0a452876 Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Tue, 11 Apr 2017 22:41:24 -0500 Subject: [PATCH 54/65] MAGETWO-67410: Create new CLI command: Collect Dependency Injection Info for the Interfaces and Classes - fixed static test --- .../Magento/Developer/Model/Di/PluginList.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Developer/Model/Di/PluginList.php b/app/code/Magento/Developer/Model/Di/PluginList.php index 12bd661414efb..121ed6bf65a3f 100644 --- a/app/code/Magento/Developer/Model/Di/PluginList.php +++ b/app/code/Magento/Developer/Model/Di/PluginList.php @@ -107,15 +107,24 @@ public function getPluginsListByClass($className) return $this->pluginList; } - foreach ($this->_inherited[$className] as $pluginKey => $plugin) { + foreach ($this->_inherited[$className] as $plugin) { foreach ($this->_definitions->getMethodList($plugin['instance']) as $pluginMethod => $methodTypes) { - $this->addPluginToList($plugin['instance'], $pluginMethod, $methodTypes, + $this->addPluginToList( + $plugin['instance'], + $pluginMethod, + $methodTypes, DefinitionInterface::LISTENER_AROUND ); - $this->addPluginToList($plugin['instance'], $pluginMethod, $methodTypes, + $this->addPluginToList( + $plugin['instance'], + $pluginMethod, + $methodTypes, DefinitionInterface::LISTENER_BEFORE ); - $this->addPluginToList($plugin['instance'], $pluginMethod, $methodTypes, + $this->addPluginToList( + $plugin['instance'], + $pluginMethod, + $methodTypes, DefinitionInterface::LISTENER_AFTER ); } @@ -130,6 +139,7 @@ public function getPluginsListByClass($className) * @param string $pluginMethod * @param int $methodTypes * @param int $typeCode + * @return void */ private function addPluginToList($pluginInstance, $pluginMethod, $methodTypes, $typeCode) { From 27418993e843498b80e9936ebf71bf8e8f2b08b4 Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Wed, 12 Apr 2017 10:02:53 +0300 Subject: [PATCH 55/65] MAGETWO-67342: L3 Javascript job green when error present in log --- package.json.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json.sample b/package.json.sample index 5460411f7e8e8..4915aa36cdea1 100644 --- a/package.json.sample +++ b/package.json.sample @@ -23,7 +23,7 @@ "grunt-contrib-watch": "^0.6.1", "grunt-eslint": "~19.0.0", "grunt-exec": "^0.4.6", - "grunt-jscs": "2.2.0", + "grunt-jscs": "~3.0.1", "grunt-replace": "^0.9.2", "grunt-styledocco": "^0.1.4", "grunt-template-jasmine-requirejs": "^0.2.3", From eaccf65c874b24defc01e76452e63756d9687aba Mon Sep 17 00:00:00 2001 From: Rafael Kassner Date: Wed, 12 Apr 2017 09:13:07 +0200 Subject: [PATCH 56/65] Do not di:compile tests/ folder --- setup/src/Magento/Setup/Console/Command/DiCompileCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 1246c93b1e10a..000403168ef97 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -227,6 +227,7 @@ private function getExcludedModulePaths(array $modulePaths) $excludedModulePaths = [ '#^(?:' . join('|', $basePathsRegExps) . ')/Test#', + '#^(?:' . join('|', $basePathsRegExps) . ')/tests#', ]; return $excludedModulePaths; } @@ -241,6 +242,7 @@ private function getExcludedLibraryPaths(array $libraryPaths) { $excludedLibraryPaths = [ '#^(?:' . join('|', $libraryPaths) . ')/([\\w]+/)?Test#', + '#^(?:' . join('|', $libraryPaths) . ')/([\\w]+/)?tests#', ]; return $excludedLibraryPaths; } From aa1e604d02efdd46b204aed91001ead313258a47 Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Wed, 12 Apr 2017 11:11:26 +0300 Subject: [PATCH 57/65] MAGETWO-67342: L3 Javascript job green when error present in log --- lib/web/mage/backend/tabs.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/web/mage/backend/tabs.js b/lib/web/mage/backend/tabs.js index 5a705ca00e1ec..849b73c20b5b2 100644 --- a/lib/web/mage/backend/tabs.js +++ b/lib/web/mage/backend/tabs.js @@ -366,9 +366,11 @@ /** * Add active tab id in data object when "beforeSubmit" event is triggered + * @param {Object} e - event object + * @param {Object} data - event data object * @protected */ - _onBeforeSubmit: function () { + _onBeforeSubmit: function (e, data) { //eslint-disable-line no-unused-vars var activeAnchor = this.activeAnchor(), activeTabId = activeAnchor.prop('id'), options; @@ -385,6 +387,7 @@ } }; options.action.args[this.options.tabIdArgument] = activeTabId; + data = data ? $.extend(data, options) : options; } }); From 3ecf591bc86d73e3dea6ece65d000b76b3786931 Mon Sep 17 00:00:00 2001 From: adragus-inviqa Date: Wed, 12 Apr 2017 10:57:16 +0100 Subject: [PATCH 58/65] Remove unused and invalid method a) there is no `$this->_getDomConfigModel()` method b) method is unused --- lib/internal/Magento/Framework/Config/View.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/internal/Magento/Framework/Config/View.php b/lib/internal/Magento/Framework/Config/View.php index a90211cba0f95..79762a298e550 100644 --- a/lib/internal/Magento/Framework/Config/View.php +++ b/lib/internal/Magento/Framework/Config/View.php @@ -133,16 +133,6 @@ public function getMediaAttributes($module, $mediaType, $mediaId) : []; } - /** - * Return copy of DOM - * - * @return \Magento\Framework\Config\Dom - */ - public function getDomConfigCopy() - { - return clone $this->_getDomConfigModel(); - } - /** * Variables are identified by module and name * From 325974364e5727c250baa362f1c962f6fec4e60b Mon Sep 17 00:00:00 2001 From: Marcel Hauri Date: Wed, 12 Apr 2017 14:42:40 +0200 Subject: [PATCH 59/65] Check if $options['value'] and $options['delete'] are set to avoid Undefined index notice inAjax return --- .../Controller/Adminhtml/Product/Attribute/Validate.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php index 81c5c688b918d..c8c3b0a37cad6 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php @@ -154,7 +154,11 @@ private function setMessageToResponse($response, $messages) */ private function checkUniqueOption(DataObject $response, array $options = null) { - if (is_array($options) && !$this->isUniqueAdminValues($options['value'], $options['delete'])) { + if ( + is_array($options) + && isset($options['value']) + && isset($options['delete']) + && !$this->isUniqueAdminValues($options['value'], $options['delete'])) { $this->setMessageToResponse($response, [__("The value of Admin must be unique.")]); $response->setError(true); } From 439113f111a10f626f1576d99ed92d11d0e1bcff Mon Sep 17 00:00:00 2001 From: Marcel Hauri Date: Wed, 12 Apr 2017 14:45:05 +0200 Subject: [PATCH 60/65] update indention for better readability --- .../Controller/Adminhtml/Product/Attribute/Validate.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php index c8c3b0a37cad6..e2e5be943f97c 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php @@ -154,11 +154,11 @@ private function setMessageToResponse($response, $messages) */ private function checkUniqueOption(DataObject $response, array $options = null) { - if ( - is_array($options) + if (is_array($options) && isset($options['value']) && isset($options['delete']) - && !$this->isUniqueAdminValues($options['value'], $options['delete'])) { + && !$this->isUniqueAdminValues($options['value'], $options['delete']) + ) { $this->setMessageToResponse($response, [__("The value of Admin must be unique.")]); $response->setError(true); } From 951605dedf61903a3f235b128af853616bf0742a Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Wed, 12 Apr 2017 13:29:45 -0500 Subject: [PATCH 61/65] MAGETWO-66424: Is Allowed Guest Checkout #7464 - fixed unit tests --- .../Observer/IsAllowedGuestCheckoutObserverTest.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/code/Magento/Downloadable/Test/Unit/Observer/IsAllowedGuestCheckoutObserverTest.php b/app/code/Magento/Downloadable/Test/Unit/Observer/IsAllowedGuestCheckoutObserverTest.php index a158455be2598..1a77933f0cd5b 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Observer/IsAllowedGuestCheckoutObserverTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Observer/IsAllowedGuestCheckoutObserverTest.php @@ -91,12 +91,8 @@ protected function setUp() */ public function testIsAllowedGuestCheckoutConfigSetToTrue($productType, $isAllowed) { - $this->resultMock->expects($this->at(0)) - ->method('setIsAllowed') - ->with(true); - if ($isAllowed) { - $this->resultMock->expects($this->at(1)) + $this->resultMock->expects($this->at(0)) ->method('setIsAllowed') ->with(false); } @@ -172,10 +168,6 @@ public function dataProviderForTestisAllowedGuestCheckoutConfigSetToTrue() public function testIsAllowedGuestCheckoutConfigSetToFalse() { - $this->resultMock->expects($this->once()) - ->method('setIsAllowed') - ->with(true); - $this->eventMock->expects($this->once()) ->method('getStore') ->will($this->returnValue($this->storeMock)); From 54c08cc1e78c9f8a484662117bf09bacb8f7639c Mon Sep 17 00:00:00 2001 From: Eugene Tulika Date: Wed, 12 Apr 2017 14:25:58 -0500 Subject: [PATCH 62/65] MAGETWO-66741: Good practice, license in readme file #6910 - Expanded the text of the license section - Changed the text of the Security news link --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6bc95cbf2a2dc..85681e2f74d6b 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,15 @@ To suggest documentation improvements, click [here][4]. To report security vulnerabilities in Magento software or web sites, please e-mail security@magento.com. Please do not report security issues using GitHub. Be sure to encrypt your e-mail with our encryption key if it includes sensitive information. Learn more about reporting security issues here. -Stay up-to-date on the latest vulnerabilities and patches for Magento by signing up for Security Alert Notifications. +Stay up-to-date on the latest security news and patches for Magento by signing up for Security Alert Notifications.

License

-OSL 3.0 (c) [Magento Inc.](https://github.com/magento/) +Each Magento source file included in this distribution is licensed under OSL 3.0 or the Magento Enterprise Edition (MEE) license + +http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +Please see LICENSE.txt for the full text of the OSL 3.0 license or contact license@magentocommerce.com for a copy. + +Subject to Licensee's payment of fees and compliance with the terms and conditions of the MEE License, the MEE License supersedes the OSL 3.0 license for each source file. +Please see LICENSE_EE.txt for the full text of the MEE License or visit http://magento.com/legal/terms/enterprise. From c985f72c45c31275bbcbd3a8062a2fcd8cd9b858 Mon Sep 17 00:00:00 2001 From: Oleksii Korshenko Date: Wed, 12 Apr 2017 15:59:28 -0500 Subject: [PATCH 63/65] MAGETWO-67404: Fix to allow Zend_Db_Expr as column default #9131 - added integration test to allow Zend_Db_Expr as column default value --- .../Framework/DB/Adapter/Pdo/MysqlTest.php | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php b/dev/tests/integration/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php index 1f20d04212678..c5e6bb6ebaaf1 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php @@ -7,6 +7,7 @@ use Magento\Framework\App\ResourceConnection; use Magento\TestFramework\Helper\CacheCleaner; +use Magento\Framework\DB\Ddl\Table; class MysqlTest extends \PHPUnit_Framework_TestCase { @@ -157,4 +158,70 @@ public function testDescribeTable() $this->getDbAdapter()->describeTable($tableName) ); } + + /** + * Test that Zend_Db_Expr can be used as a column default value. + * @see https://github.com/magento/magento2/pull/9131 + */ + public function testCreateTableColumnWithExpressionAsColumnDefaultValue() + { + $adapter = $this->getDbAdapter(); + $tableName = 'table_column_with_expression_as_column_default_value'; + + $table = $adapter + ->newTable($tableName) + ->addColumn( + 'row_id', + Table::TYPE_INTEGER, + null, + ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], + 'Row Id' + ) + ->addColumn( + 'created_at', + Table::TYPE_DATETIME, + null, + ['default' => new \Zend_Db_Expr('CURRENT_TIMESTAMP')] + ) + ->addColumn( + 'integer_column', + Table::TYPE_INTEGER, + 11, + ['default' => 123456] + )->addColumn( + 'string_column', + Table::TYPE_TEXT, + 255, + ['default' => 'default test text'] + ) + ->setComment('Test table column with expression as column default value'); + $adapter->createTable($table); + + $tableDescription = $adapter->describeTable($tableName); + + //clean up database from test table + $adapter->dropTable($tableName); + + $this->assertArrayHasKey('created_at', $tableDescription, 'Column created_at does not exists'); + $this->assertArrayHasKey('integer_column', $tableDescription, 'Column integer_column does not exists'); + $this->assertArrayHasKey('string_column', $tableDescription, 'Column string_column does not exists'); + $dateColumn = $tableDescription['created_at']; + $intColumn = $tableDescription['integer_column']; + $stringColumn = $tableDescription['string_column']; + + //Test default value with expression + $this->assertEquals('created_at', $dateColumn['COLUMN_NAME'], 'Incorrect column name'); + $this->assertEquals(Table::TYPE_DATETIME, $dateColumn['DATA_TYPE'], 'Incorrect column type'); + $this->assertEquals('CURRENT_TIMESTAMP', $dateColumn['DEFAULT'], 'Incorrect column default expression value'); + + //Test default value with integer value + $this->assertEquals('integer_column', $intColumn['COLUMN_NAME'], 'Incorrect column name'); + $this->assertEquals('int', $intColumn['DATA_TYPE'], 'Incorrect column type'); + $this->assertEquals(123456, $intColumn['DEFAULT'], 'Incorrect column default integer value'); + + //Test default value with string value + $this->assertEquals('string_column', $stringColumn['COLUMN_NAME'], 'Incorrect column name'); + $this->assertEquals('varchar', $stringColumn['DATA_TYPE'], 'Incorrect column type'); + $this->assertEquals('default test text', $stringColumn['DEFAULT'], 'Incorrect column default string value'); + } } From 96ccee2eb8bddf4ce627b2ec97daa5191c8c2608 Mon Sep 17 00:00:00 2001 From: Oleksii Korshenko Date: Wed, 12 Apr 2017 16:22:58 -0500 Subject: [PATCH 64/65] MAGETWO-67409: Collection walk method bug fix when specific callback function #5742 - covered fix with unit test --- .../Magento/Framework/Data/Collection.php | 2 +- .../Test/Unit/Data/CollectionTest.php | 70 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 lib/internal/Magento/Framework/Test/Unit/Data/CollectionTest.php diff --git a/lib/internal/Magento/Framework/Data/Collection.php b/lib/internal/Magento/Framework/Data/Collection.php index 358842d71e7b9..be16258450303 100644 --- a/lib/internal/Magento/Framework/Data/Collection.php +++ b/lib/internal/Magento/Framework/Data/Collection.php @@ -500,7 +500,7 @@ public function clear() */ public function walk($callback, array $args = []) { - $results = []; + $results = []; $useItemCallback = is_string($callback) && strpos($callback, '::') === false; foreach ($this->getItems() as $id => $item) { $params = $args; diff --git a/lib/internal/Magento/Framework/Test/Unit/Data/CollectionTest.php b/lib/internal/Magento/Framework/Test/Unit/Data/CollectionTest.php new file mode 100644 index 0000000000000..34ad9068160ea --- /dev/null +++ b/lib/internal/Magento/Framework/Test/Unit/Data/CollectionTest.php @@ -0,0 +1,70 @@ +getMock(EntityFactoryInterface::class); + $this->collection = new Collection($factoryMock); + } + + /** + * Test that callback works correctly for all items in collection. + * @see https://github.com/magento/magento2/pull/5742 + */ + public function testWalk() + { + $objOne = new \Magento\Framework\DataObject(['id' => 1, 'name' => 'one']); + $objTwo = new \Magento\Framework\DataObject(['id' => 2, 'name' => 'two']); + $objThree = new \Magento\Framework\DataObject(['id' => 3, 'name' => 'three']); + + $this->collection->addItem($objOne); + $this->collection->addItem($objTwo); + $this->collection->addItem($objThree); + + $this->assertEquals([1, 2, 3], $this->collection->getAllIds(), 'Items added incorrectly to the collection'); + $this->collection->walk([$this, 'modifyObjectNames'], ['test prefix']); + + $this->assertEquals([1, 2, 3], $this->collection->getAllIds(), 'Incorrect IDs after callback function'); + $expectedNames = [ + 'test prefix one', + 'test prefix two', + 'test prefix three' + ]; + + $this->assertEquals( + $expectedNames, + $this->collection->getColumnValues('name'), + 'Incorrect Names after callback function' + ); + } + + /** + * Callback function. + * + * @param \Magento\Framework\DataObject $object + * @param string $prefix + */ + public function modifyObjectNames(\Magento\Framework\DataObject $object, $prefix) + { + $object->setData('name', $prefix . ' ' . $object->getData('name')); + } +} From 3f587316ae69bb96acdf78b5cd67827d8ebb5d08 Mon Sep 17 00:00:00 2001 From: Oleksii Korshenko Date: Wed, 12 Apr 2017 20:28:10 -0500 Subject: [PATCH 65/65] MAGETWO-67405: Improved text of exception message in case of error in module's composer.json #9165 --- lib/internal/Magento/Framework/Module/PackageInfo.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Module/PackageInfo.php b/lib/internal/Magento/Framework/Module/PackageInfo.php index a80d234d43369..1fa4c6b824f15 100644 --- a/lib/internal/Magento/Framework/Module/PackageInfo.php +++ b/lib/internal/Magento/Framework/Module/PackageInfo.php @@ -74,6 +74,8 @@ public function __construct(Dir\Reader $reader, ComponentRegistrar $componentReg * Load the packages information * * @return void + * @throws \Zend_Json_Exception + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ private function load() { @@ -239,7 +241,7 @@ public function getRequiredBy($requiredModuleName) $requiredBy[] = $moduleName; } } - + return $requiredBy; }