diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php index be502cbd411cc..6635ccbc83fc9 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php @@ -275,11 +275,16 @@ public function getGridIdsJson() if (!$this->getUseSelectAll()) { return ''; } - /** @var \Magento\Framework\Data\Collection $allIdsCollection */ $allIdsCollection = clone $this->getParentBlock()->getCollection(); - $gridIds = $allIdsCollection->clear()->setPageSize(0)->getAllIds(); - + + if ($this->getMassactionIdField()) { + $massActionIdField = $this->getMassactionIdField(); + } else { + $massActionIdField = $this->getParentBlock()->getMassactionIdField(); + } + + $gridIds = $allIdsCollection->setPageSize(0)->getColumnValues($massActionIdField); if (!empty($gridIds)) { return join(",", $gridIds); } diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php index b0b7f9d730fe6..ce46632cfba05 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php @@ -274,7 +274,14 @@ public function getGridIdsJson() /** @var \Magento\Framework\Data\Collection $allIdsCollection */ $allIdsCollection = clone $this->getParentBlock()->getCollection(); - $gridIds = $allIdsCollection->clear()->setPageSize(0)->getAllIds(); + + if ($this->getMassactionIdField()) { + $massActionIdField = $this->getMassactionIdField(); + } else { + $massActionIdField = $this->getParentBlock()->getMassactionIdField(); + } + + $gridIds = $allIdsCollection->setPageSize(0)->getColumnValues($massActionIdField); if (!empty($gridIds)) { return join(",", $gridIds); diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php index e6e2a1904daf7..f42ec575fdcc3 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php @@ -132,7 +132,13 @@ public function testGetGridIdsJsonWithoutUseSelectAll() public function testGetGridIdsJsonWithUseSelectAll(array $items, $result) { $this->_block->setUseSelectAll(true); - + + if ($this->_block->getMassactionIdField()) { + $massActionIdField = $this->_block->getMassactionIdField(); + } else { + $massActionIdField = $this->_block->getParentBlock()->getMassactionIdField(); + } + $collectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection::class) ->disableOriginalConstructor() ->getMock(); @@ -141,15 +147,13 @@ public function testGetGridIdsJsonWithUseSelectAll(array $items, $result) ->method('getCollection') ->willReturn($collectionMock); - $collectionMock->expects($this->once()) - ->method('clear') - ->willReturnSelf(); $collectionMock->expects($this->once()) ->method('setPageSize') ->with(0) ->willReturnSelf(); $collectionMock->expects($this->once()) - ->method('getAllIds') + ->method('getColumnValues') + ->with($massActionIdField) ->willReturn($items); $this->assertEquals($result, $this->_block->getGridIdsJson()); diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php index d8ecfc14d2697..86ab5ebd7761b 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php @@ -237,6 +237,12 @@ public function testGetGridIdsJsonWithoutUseSelectAll() public function testGetGridIdsJsonWithUseSelectAll(array $items, $result) { $this->_block->setUseSelectAll(true); + + if ($this->_block->getMassactionIdField()) { + $massActionIdField = $this->_block->getMassactionIdField(); + } else { + $massActionIdField = $this->_block->getParentBlock()->getMassactionIdField(); + } $collectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection::class) ->disableOriginalConstructor() @@ -245,16 +251,13 @@ public function testGetGridIdsJsonWithUseSelectAll(array $items, $result) $this->_gridMock->expects($this->once()) ->method('getCollection') ->willReturn($collectionMock); - - $collectionMock->expects($this->once()) - ->method('clear') - ->willReturnSelf(); $collectionMock->expects($this->once()) ->method('setPageSize') ->with(0) ->willReturnSelf(); $collectionMock->expects($this->once()) - ->method('getAllIds') + ->method('getColumnValues') + ->with($massActionIdField) ->willReturn($items); $this->assertEquals($result, $this->_block->getGridIdsJson()); diff --git a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php index e30b1541d8b5f..31bb015371e1f 100644 --- a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php +++ b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php @@ -96,6 +96,11 @@ class AbstractProduct extends \Magento\Framework\View\Element\Template */ protected $stockRegistry; + /** + * @var ImageBuilder + */ + protected $imageBuilder; + /** * @param Context $context * @param array $data diff --git a/app/code/Magento/Paypal/Model/Api/ProcessableException.php b/app/code/Magento/Paypal/Model/Api/ProcessableException.php index e455cf3128428..71225cf8cb3f3 100644 --- a/app/code/Magento/Paypal/Model/Api/ProcessableException.php +++ b/app/code/Magento/Paypal/Model/Api/ProcessableException.php @@ -40,7 +40,7 @@ class ProcessableException extends LocalizedException */ public function __construct(Phrase $phrase, \Exception $cause = null, $code = 0) { - parent::__construct($phrase, $cause); + parent::__construct($phrase, $cause, $code); $this->code = $code; } diff --git a/app/code/Magento/Search/Model/Synonym/MergeConflictException.php b/app/code/Magento/Search/Model/Synonym/MergeConflictException.php index 2c0ab409b47c5..34b1af0bf949c 100644 --- a/app/code/Magento/Search/Model/Synonym/MergeConflictException.php +++ b/app/code/Magento/Search/Model/Synonym/MergeConflictException.php @@ -28,10 +28,11 @@ class MergeConflictException extends LocalizedException * @param array $conflictingSynonyms * @param Phrase|null $phrase * @param \Exception|null $cause + * @param int $code */ - public function __construct(array $conflictingSynonyms, Phrase $phrase = null, \Exception $cause = null) + public function __construct(array $conflictingSynonyms, Phrase $phrase = null, \Exception $cause = null, $code = 0) { - parent::__construct($phrase, $cause); + parent::__construct($phrase, $cause, $code); $this->conflictingSynonyms = $conflictingSynonyms; } diff --git a/app/code/Magento/Store/Model/StoreIsInactiveException.php b/app/code/Magento/Store/Model/StoreIsInactiveException.php index 00293e9c45013..545fb0e9d81b7 100644 --- a/app/code/Magento/Store/Model/StoreIsInactiveException.php +++ b/app/code/Magento/Store/Model/StoreIsInactiveException.php @@ -16,12 +16,13 @@ class StoreIsInactiveException extends LocalizedException /** * @param \Magento\Framework\Phrase $phrase * @param \Exception $cause + * @param int $code */ - public function __construct(Phrase $phrase = null, \Exception $cause = null) + public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0) { if ($phrase === null) { $phrase = new Phrase('Store is inactive'); } - parent::__construct($phrase, $cause); + parent::__construct($phrase, $cause, $code); } } diff --git a/lib/internal/Magento/Framework/App/ResourceConnection/Config.php b/lib/internal/Magento/Framework/App/ResourceConnection/Config.php index 6c133ea3bae75..9077ff649d364 100644 --- a/lib/internal/Magento/Framework/App/ResourceConnection/Config.php +++ b/lib/internal/Magento/Framework/App/ResourceConnection/Config.php @@ -63,9 +63,7 @@ public function getConnectionName($resourceName) { $this->initConnections(); $connectionName = \Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION; - - $resourceName = preg_replace("/_setup$/", '', $resourceName); - + if (!isset($this->_connectionNames[$resourceName])) { $resourcesConfig = $this->get(); $pointerResourceName = $resourceName; diff --git a/lib/internal/Magento/Framework/Config/etc/view.xsd b/lib/internal/Magento/Framework/Config/etc/view.xsd index 23ddb318fe0a2..20b6a7d4fbfd2 100644 --- a/lib/internal/Magento/Framework/Config/etc/view.xsd +++ b/lib/internal/Magento/Framework/Config/etc/view.xsd @@ -38,10 +38,10 @@ - - - - + + + + diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Editablemultiselect.php b/lib/internal/Magento/Framework/Data/Form/Element/Editablemultiselect.php index 8df9b4175675f..3c03155fb163e 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Editablemultiselect.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Editablemultiselect.php @@ -13,8 +13,36 @@ */ namespace Magento\Framework\Data\Form\Element; +use Magento\Framework\Escaper; + class Editablemultiselect extends \Magento\Framework\Data\Form\Element\Multiselect { + /** + * @var \Magento\Framework\Serialize\Serializer\Json + */ + private $serializer; + + /** + * Editablemultiselect constructor. + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper + * @param array $data + * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer + * @throws \RuntimeException + */ + public function __construct( + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, + array $data = [], + \Magento\Framework\Serialize\Serializer\Json $serializer = null + ) { + parent::__construct($factoryElement, $factoryCollection, $escaper, $data); + $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Framework\Serialize\Serializer\Json::class); + } + /** * Name of the default JavaScript class that is used to make multiselect editable * @@ -26,6 +54,7 @@ class Editablemultiselect extends \Magento\Framework\Data\Form\Element\Multisele * Retrieve HTML markup of the element * * @return string + * @throws \InvalidArgumentException */ public function getElementHtml() { @@ -41,7 +70,7 @@ public function getElementHtml() $elementJsClass = $this->getData('element_js_class'); } - $selectConfigJson = \Zend_Json::encode($selectConfig); + $selectConfigJson = $this->serializer->serialize($selectConfig); $jsObjectName = $this->getJsObjectName(); // TODO: TaxRateEditableMultiselect should be moved to a static .js module. diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Editor.php b/lib/internal/Magento/Framework/Data/Form/Element/Editor.php index 50d553f5e06ab..6ed2d8293e61d 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Editor.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Editor.php @@ -16,16 +16,25 @@ class Editor extends Textarea { /** + * @var \Magento\Framework\Serialize\Serializer\Json + */ + private $serializer; + + /** + * Editor constructor. * @param Factory $factoryElement * @param CollectionFactory $factoryCollection * @param Escaper $escaper * @param array $data + * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer + * @throws \RuntimeException */ public function __construct( Factory $factoryElement, CollectionFactory $factoryCollection, Escaper $escaper, - $data = [] + $data = [], + \Magento\Framework\Serialize\Serializer\Json $serializer = null ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -36,6 +45,8 @@ public function __construct( $this->setType('textarea'); $this->setExtType('textarea'); } + $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Framework\Serialize\Serializer\Json::class); } /** @@ -52,6 +63,21 @@ protected function getButtonTranslations() return $buttonTranslations; } + /** + * @return bool|string + * @throws \InvalidArgumentException + */ + private function getJsonConfig() + { + if (is_object($this->getConfig()) && method_exists($this->getConfig(), 'toJson')) { + return $this->getConfig()->toJson(); + } else { + return $this->serializer->serialize( + $this->getConfig() + ); + } + } + /** * @return string * @SuppressWarnings(PHPMD.ExcessiveMethodLength) @@ -132,7 +158,7 @@ public function getElementHtml() ], function(jQuery){' . "\n" . ' (function($) {$.mage.translate.add(' . - \Zend_Json::encode( + $this->serializer->serialize( $this->getButtonTranslations() ) . ')})(jQuery);' . @@ -141,9 +167,7 @@ public function getElementHtml() ' = new tinyMceWysiwygSetup("' . $this->getHtmlId() . '", ' . - \Zend_Json::encode( - $this->getConfig() - ) . + $this->getJsonConfig() . ');' . $forceLoad . ' @@ -180,7 +204,7 @@ public function getElementHtml() //getButtonTranslations()) . ') + $.mage.translate.add(' . $this->serializer->serialize($this->getButtonTranslations()) . ') })(jQuery); }); //]]> diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditorTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditorTest.php index 8f635d0cddfa1..ae0445b9550ea 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditorTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/EditorTest.php @@ -48,6 +48,11 @@ class EditorTest extends \PHPUnit_Framework_TestCase */ protected $objectManager; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $serializer; + protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -62,13 +67,16 @@ protected function setUp() $this->escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); $this->configMock = $this->getMock(\Magento\Framework\DataObject::class, ['getData'], [], '', false); + $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false); + $this->model = $this->objectManager->getObject( \Magento\Framework\Data\Form\Element\Editor::class, [ 'factoryElement' => $this->factoryMock, 'factoryCollection' => $this->collectionFactoryMock, 'escaper' => $this->escaperMock, - 'data' => ['config' => $this->configMock] + 'data' => ['config' => $this->configMock], + 'serializer' => $this->serializer ] ); @@ -202,8 +210,17 @@ public function testGetConfig() */ public function testGetTranslatedString() { + $callback = function ($params) { + return json_encode($params); + }; + $this->configMock->expects($this->any())->method('getData')->withConsecutive(['enabled'])->willReturn(true); + $this->serializer->expects($this->any()) + ->method('serialize') + ->willReturnCallback($callback); + $html = $this->model->getElementHtml(); + $this->assertRegExp('/.*"Insert Image...":"Insert Image...".*/i', $html); } } diff --git a/lib/internal/Magento/Framework/Exception/AbstractAggregateException.php b/lib/internal/Magento/Framework/Exception/AbstractAggregateException.php index 14e711429827c..56c3bd285bc1e 100644 --- a/lib/internal/Magento/Framework/Exception/AbstractAggregateException.php +++ b/lib/internal/Magento/Framework/Exception/AbstractAggregateException.php @@ -39,11 +39,12 @@ abstract class AbstractAggregateException extends LocalizedException * * @param \Magento\Framework\Phrase $phrase * @param \Exception $cause + * @param int $code */ - public function __construct(Phrase $phrase, \Exception $cause = null) + public function __construct(Phrase $phrase, \Exception $cause = null, $code = 0) { $this->originalPhrase = $phrase; - parent::__construct($phrase, $cause); + parent::__construct($phrase, $cause, $code); } /** diff --git a/lib/internal/Magento/Framework/Exception/AlreadyExistsException.php b/lib/internal/Magento/Framework/Exception/AlreadyExistsException.php index 1917385148031..cc1206623a2fb 100644 --- a/lib/internal/Magento/Framework/Exception/AlreadyExistsException.php +++ b/lib/internal/Magento/Framework/Exception/AlreadyExistsException.php @@ -15,12 +15,13 @@ class AlreadyExistsException extends LocalizedException /** * @param Phrase $phrase * @param \Exception $cause + * @param int $code */ - public function __construct(Phrase $phrase = null, \Exception $cause = null) + public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0) { if ($phrase === null) { $phrase = new Phrase('Unique constraint violation found'); } - parent::__construct($phrase, $cause); + parent::__construct($phrase, $cause, $code); } } diff --git a/lib/internal/Magento/Framework/Exception/InputException.php b/lib/internal/Magento/Framework/Exception/InputException.php index 2dc3033be1da5..2496326681e7b 100644 --- a/lib/internal/Magento/Framework/Exception/InputException.php +++ b/lib/internal/Magento/Framework/Exception/InputException.php @@ -49,13 +49,14 @@ class InputException extends AbstractAggregateException * * @param \Magento\Framework\Phrase $phrase * @param \Exception $cause + * @param int $code */ - public function __construct(Phrase $phrase = null, \Exception $cause = null) + public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0) { if ($phrase === null) { $phrase = new Phrase('One or more input exceptions have occurred.'); } - parent::__construct($phrase, $cause); + parent::__construct($phrase, $cause, $code); } /** diff --git a/lib/internal/Magento/Framework/Exception/NoSuchEntityException.php b/lib/internal/Magento/Framework/Exception/NoSuchEntityException.php index 6e160c6ec6da2..42b30d45e4c72 100644 --- a/lib/internal/Magento/Framework/Exception/NoSuchEntityException.php +++ b/lib/internal/Magento/Framework/Exception/NoSuchEntityException.php @@ -27,13 +27,14 @@ class NoSuchEntityException extends LocalizedException /** * @param \Magento\Framework\Phrase $phrase * @param \Exception $cause + * @param int $code */ - public function __construct(Phrase $phrase = null, \Exception $cause = null) + public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0) { if ($phrase === null) { $phrase = new Phrase('No such entity.'); } - parent::__construct($phrase, $cause); + parent::__construct($phrase, $cause, $code); } /** diff --git a/lib/internal/Magento/Framework/Exception/SerializationException.php b/lib/internal/Magento/Framework/Exception/SerializationException.php index 5346425a9b545..27d0bc0c4371a 100644 --- a/lib/internal/Magento/Framework/Exception/SerializationException.php +++ b/lib/internal/Magento/Framework/Exception/SerializationException.php @@ -27,12 +27,13 @@ class SerializationException extends LocalizedException /** * @param \Magento\Framework\Phrase $phrase * @param \Exception $cause + * @param int $code */ - public function __construct(Phrase $phrase = null, \Exception $cause = null) + public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0) { if ($phrase === null) { $phrase = new Phrase('One or more input exceptions have occurred.'); } - parent::__construct($phrase, $cause); + parent::__construct($phrase, $cause, $code); } } diff --git a/lib/internal/Magento/Framework/Exception/TemporaryState/CouldNotSaveException.php b/lib/internal/Magento/Framework/Exception/TemporaryState/CouldNotSaveException.php index d8ce8dee035db..807bb2d31a498 100644 --- a/lib/internal/Magento/Framework/Exception/TemporaryState/CouldNotSaveException.php +++ b/lib/internal/Magento/Framework/Exception/TemporaryState/CouldNotSaveException.php @@ -25,7 +25,7 @@ class CouldNotSaveException extends LocalizedCouldNotSaveException implements Te */ public function __construct(Phrase $phrase, \Exception $previous = null, $code = 0) { - parent::__construct($phrase, $previous); + parent::__construct($phrase, $previous, $code); $this->code = $code; } } diff --git a/lib/internal/Magento/Framework/Validator/Exception.php b/lib/internal/Magento/Framework/Validator/Exception.php index 0e245b2a4a7e9..c70ecfabb52af 100644 --- a/lib/internal/Magento/Framework/Validator/Exception.php +++ b/lib/internal/Magento/Framework/Validator/Exception.php @@ -30,11 +30,13 @@ class Exception extends InputException * @param \Magento\Framework\Phrase $phrase * @param \Exception $cause * @param array $messages Validation error messages + * @param int $code */ public function __construct( Phrase $phrase = null, \Exception $cause = null, - array $messages = [] + array $messages = [], + $code = 0 ) { if (!empty($messages)) { $message = ''; @@ -49,7 +51,7 @@ public function __construct( } $phrase = new Phrase($message); } - parent::__construct($phrase, $cause); + parent::__construct($phrase, $cause, $code); } /** diff --git a/lib/internal/Magento/Framework/View/Page/Config/Reader/Head.php b/lib/internal/Magento/Framework/View/Page/Config/Reader/Head.php index 71714084941e3..8328f03fd6db5 100644 --- a/lib/internal/Magento/Framework/View/Page/Config/Reader/Head.php +++ b/lib/internal/Magento/Framework/View/Page/Config/Reader/Head.php @@ -86,7 +86,7 @@ public function interpret( break; case self::HEAD_TITLE: - $pageConfigStructure->setTitle($node); + $pageConfigStructure->setTitle(new \Magento\Framework\Phrase($node)); break; case self::HEAD_META: diff --git a/lib/internal/Magento/Framework/Webapi/Exception.php b/lib/internal/Magento/Framework/Webapi/Exception.php index 01a9848c63282..97ebbc40865ab 100644 --- a/lib/internal/Magento/Framework/Webapi/Exception.php +++ b/lib/internal/Magento/Framework/Webapi/Exception.php @@ -105,7 +105,7 @@ public function __construct( if ($httpCode < 400 || $httpCode > 599) { throw new \InvalidArgumentException(sprintf('The specified HTTP code "%d" is invalid.', $httpCode)); } - parent::__construct($phrase); + parent::__construct($phrase, null, $code); $this->code = $code; $this->_httpCode = $httpCode; $this->_details = $details;