- getUnreadMessages() as $message): ?>
- -
- = /* @escapeNotVerified */ $message->getText() ?>
+ getUnreadMessages() as $message) : ?>
+
-
+ = $block->escapeHtml($message->getText()) ?>
diff --git a/app/code/Magento/AdminNotification/view/adminhtml/templates/toolbar_entry.phtml b/app/code/Magento/AdminNotification/view/adminhtml/templates/toolbar_entry.phtml
index 777448cdd82b4..38398727e0f90 100644
--- a/app/code/Magento/AdminNotification/view/adminhtml/templates/toolbar_entry.phtml
+++ b/app/code/Magento/AdminNotification/view/adminhtml/templates/toolbar_entry.phtml
@@ -4,81 +4,78 @@
* See COPYING.txt for license details.
*/
-// @codingStandardsIgnoreFile
+/** @var $this \Magento\AdminNotification\Block\ToolbarEntry */
-?>
-
-getUnreadNotificationCount();
$notificationCounterMax = $block->getNotificationCounterMax();
?>
diff --git a/app/code/Magento/AmqpStore/LICENSE.txt b/app/code/Magento/AmqpStore/LICENSE.txt
new file mode 100644
index 0000000000000..49525fd99da9c
--- /dev/null
+++ b/app/code/Magento/AmqpStore/LICENSE.txt
@@ -0,0 +1,48 @@
+
+Open Software License ("OSL") v. 3.0
+
+This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
+
+Licensed under the Open Software License version 3.0
+
+ 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
+
+ 1. to reproduce the Original Work in copies, either alone or as part of a collective work;
+
+ 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
+
+ 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License;
+
+ 4. to perform the Original Work publicly; and
+
+ 5. to display the Original Work publicly.
+
+ 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
+
+ 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
+
+ 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
+
+ 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
+
+ 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
+
+ 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
+
+ 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
+
+ 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
+
+ 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
+
+ 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
+
+ 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
+
+ 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
+
+ 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+ 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
+
+ 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under
" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
\ No newline at end of file
diff --git a/app/code/Magento/AmqpStore/LICENSE_AFL.txt b/app/code/Magento/AmqpStore/LICENSE_AFL.txt
new file mode 100644
index 0000000000000..f39d641b18a19
--- /dev/null
+++ b/app/code/Magento/AmqpStore/LICENSE_AFL.txt
@@ -0,0 +1,48 @@
+
+Academic Free License ("AFL") v. 3.0
+
+This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
+
+Licensed under the Academic Free License version 3.0
+
+ 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
+
+ 1. to reproduce the Original Work in copies, either alone or as part of a collective work;
+
+ 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
+
+ 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License;
+
+ 4. to perform the Original Work publicly; and
+
+ 5. to display the Original Work publicly.
+
+ 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
+
+ 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
+
+ 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
+
+ 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
+
+ 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
+
+ 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
+
+ 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
+
+ 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
+
+ 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
+
+ 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
+
+ 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
+
+ 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
+
+ 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+ 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
+
+ 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
diff --git a/app/code/Magento/AmqpStore/Plugin/AsynchronousOperations/MassConsumerEnvelopeCallback.php b/app/code/Magento/AmqpStore/Plugin/AsynchronousOperations/MassConsumerEnvelopeCallback.php
new file mode 100644
index 0000000000000..e05004cea78cd
--- /dev/null
+++ b/app/code/Magento/AmqpStore/Plugin/AsynchronousOperations/MassConsumerEnvelopeCallback.php
@@ -0,0 +1,101 @@
+storeManager = $storeManager;
+ $this->envelopeFactory = $envelopeFactory;
+ $this->logger = $logger;
+ }
+
+ /**
+ * Check if amqpProperties['application_headers'] have 'store_id' and use it to setCurrentStore
+ * Restore original store value in consumer process after execution.
+ * Reject queue messages because of wrong store_id.
+ *
+ * @param SubjectMassConsumerEnvelopeCallback $subject
+ * @param callable $proceed
+ * @param EnvelopeInterface $message
+ * @return void
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function aroundExecute(
+ SubjectMassConsumerEnvelopeCallback $subject,
+ callable $proceed,
+ EnvelopeInterface $message
+ ) {
+ $amqpProperties = $message->getProperties();
+ if (isset($amqpProperties['application_headers'])) {
+ $headers = $amqpProperties['application_headers'];
+ if ($headers instanceof AMQPTable) {
+ $headers = $headers->getNativeData();
+ }
+ if (isset($headers['store_id'])) {
+ $storeId = $headers['store_id'];
+ try {
+ $currentStoreId = $this->storeManager->getStore()->getId();
+ } catch (NoSuchEntityException $e) {
+ $this->logger->error(
+ sprintf(
+ "Can't set currentStoreId during processing queue. Message rejected. Error %s.",
+ $e->getMessage()
+ )
+ );
+ $subject->getQueue()->reject($message, false, $e->getMessage());
+ return;
+ }
+ if (isset($storeId) && $storeId !== $currentStoreId) {
+ $this->storeManager->setCurrentStore($storeId);
+ }
+ }
+ }
+ $proceed($message);
+ if (isset($storeId, $currentStoreId) && $storeId !== $currentStoreId) {
+ $this->storeManager->setCurrentStore($currentStoreId);//restore original store value
+ }
+ }
+}
diff --git a/app/code/Magento/AmqpStore/Plugin/Framework/Amqp/Bulk/Exchange.php b/app/code/Magento/AmqpStore/Plugin/Framework/Amqp/Bulk/Exchange.php
new file mode 100644
index 0000000000000..c5db1f5300c29
--- /dev/null
+++ b/app/code/Magento/AmqpStore/Plugin/Framework/Amqp/Bulk/Exchange.php
@@ -0,0 +1,117 @@
+storeManager = $storeManager;
+ $this->envelopeFactory = $envelopeFactory;
+ $this->logger = $logger;
+ }
+
+ /**
+ * Set current store_id in amqpProperties['application_headers']
+ * so consumer may check store_id and execute operation in correct store scope.
+ * Prevent publishing inconsistent messages because of store_id not defined or wrong.
+ *
+ * @param SubjectExchange $subject
+ * @param string $topic
+ * @param EnvelopeInterface[] $envelopes
+ * @return array
+ * @throws AMQPInvalidArgumentException
+ * @throws \LogicException
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function beforeEnqueue(SubjectExchange $subject, $topic, array $envelopes)
+ {
+ try {
+ $storeId = $this->storeManager->getStore()->getId();
+ } catch (NoSuchEntityException $e) {
+ $errorMessage = sprintf(
+ "Can't get current storeId and inject to amqp message. Error %s.",
+ $e->getMessage()
+ );
+ $this->logger->error($errorMessage);
+ throw new \LogicException($errorMessage);
+ }
+
+ $updatedEnvelopes = [];
+ foreach ($envelopes as $envelope) {
+ $properties = $envelope->getProperties();
+ if (!isset($properties)) {
+ $properties = [];
+ }
+ if (isset($properties['application_headers'])) {
+ $headers = $properties['application_headers'];
+ if ($headers instanceof AMQPTable) {
+ try {
+ $headers->set('store_id', $storeId);
+ // phpcs:ignore Magento2.Exceptions.ThrowCatch
+ } catch (AMQPInvalidArgumentException $ea) {
+ $errorMessage = sprintf("Can't set storeId to amqp message. Error %s.", $ea->getMessage());
+ $this->logger->error($errorMessage);
+ throw new AMQPInvalidArgumentException($errorMessage);
+ }
+ $properties['application_headers'] = $headers;
+ }
+ } else {
+ $properties['application_headers'] = new AMQPTable(['store_id' => $storeId]);
+ }
+ $updatedEnvelopes[] = $this->envelopeFactory->create(
+ [
+ 'body' => $envelope->getBody(),
+ 'properties' => $properties
+ ]
+ );
+ }
+ if (!empty($updatedEnvelopes)) {
+ $envelopes = $updatedEnvelopes;
+ }
+ return [$topic, $envelopes];
+ }
+}
diff --git a/app/code/Magento/AmqpStore/README.md b/app/code/Magento/AmqpStore/README.md
new file mode 100644
index 0000000000000..0f84c8ff3276e
--- /dev/null
+++ b/app/code/Magento/AmqpStore/README.md
@@ -0,0 +1,3 @@
+# Amqp Store
+
+**AmqpStore** provides ability to specify store before publish messages with Amqp.
diff --git a/app/code/Magento/AmqpStore/composer.json b/app/code/Magento/AmqpStore/composer.json
new file mode 100644
index 0000000000000..bd11527bbb36e
--- /dev/null
+++ b/app/code/Magento/AmqpStore/composer.json
@@ -0,0 +1,30 @@
+{
+ "name": "magento/module-amqp-store",
+ "description": "N/A",
+ "config": {
+ "sort-packages": true
+ },
+ "require": {
+ "magento/framework": "*",
+ "magento/framework-amqp": "*",
+ "magento/module-store": "*",
+ "php": "~7.1.3||~7.2.0"
+ },
+ "suggest": {
+ "magento/module-asynchronous-operations": "*",
+ "magento/framework-message-queue": "*"
+ },
+ "type": "magento2-module",
+ "license": [
+ "OSL-3.0",
+ "AFL-3.0"
+ ],
+ "autoload": {
+ "files": [
+ "registration.php"
+ ],
+ "psr-4": {
+ "Magento\\AmqpStore\\": ""
+ }
+ }
+}
diff --git a/app/code/Magento/AmqpStore/etc/di.xml b/app/code/Magento/AmqpStore/etc/di.xml
new file mode 100644
index 0000000000000..3bbbebd249535
--- /dev/null
+++ b/app/code/Magento/AmqpStore/etc/di.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/AmqpStore/etc/module.xml b/app/code/Magento/AmqpStore/etc/module.xml
new file mode 100644
index 0000000000000..085b97b5e2f96
--- /dev/null
+++ b/app/code/Magento/AmqpStore/etc/module.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/AmqpStore/registration.php b/app/code/Magento/AmqpStore/registration.php
new file mode 100644
index 0000000000000..4922879bfbf16
--- /dev/null
+++ b/app/code/Magento/AmqpStore/registration.php
@@ -0,0 +1,9 @@
+invoker = $invoker;
- $this->resource = $resource;
- $this->messageController = $messageController;
$this->configuration = $configuration;
- $this->operationProcessor = $operationProcessorFactory->create([
- 'configuration' => $configuration
- ]);
- $this->logger = $logger;
+ $this->massConsumerEnvelopeCallback = $massConsumerEnvelopeCallback;
$this->registry = $registry ?? \Magento\Framework\App\ObjectManager::getInstance()
->get(Registry::class);
}
@@ -122,38 +89,14 @@ public function process($maxNumberOfMessages = null)
*/
private function getTransactionCallback(QueueInterface $queue)
{
- return function (EnvelopeInterface $message) use ($queue) {
- /** @var LockInterface $lock */
- $lock = null;
- try {
- $topicName = $message->getProperties()['topic_name'];
- $lock = $this->messageController->lock($message, $this->configuration->getConsumerName());
-
- $allowedTopics = $this->configuration->getTopicNames();
- if (in_array($topicName, $allowedTopics)) {
- $this->operationProcessor->process($message->getBody());
- } else {
- $queue->reject($message);
- return;
- }
- $queue->acknowledge($message);
- } catch (MessageLockException $exception) {
- $queue->acknowledge($message);
- } catch (ConnectionLostException $e) {
- if ($lock) {
- $this->resource->getConnection()
- ->delete($this->resource->getTableName('queue_lock'), ['id = ?' => $lock->getId()]);
- }
- } catch (NotFoundException $e) {
- $queue->acknowledge($message);
- $this->logger->warning($e->getMessage());
- } catch (\Exception $e) {
- $queue->reject($message, false, $e->getMessage());
- if ($lock) {
- $this->resource->getConnection()
- ->delete($this->resource->getTableName('queue_lock'), ['id = ?' => $lock->getId()]);
- }
- }
+ $callbackInstance = $this->massConsumerEnvelopeCallback->create(
+ [
+ 'configuration' => $this->configuration,
+ 'queue' => $queue,
+ ]
+ );
+ return function (EnvelopeInterface $message) use ($callbackInstance) {
+ $callbackInstance->execute($message);
};
}
}
diff --git a/app/code/Magento/AsynchronousOperations/Model/MassConsumerEnvelopeCallback.php b/app/code/Magento/AsynchronousOperations/Model/MassConsumerEnvelopeCallback.php
new file mode 100644
index 0000000000000..42437292e6f00
--- /dev/null
+++ b/app/code/Magento/AsynchronousOperations/Model/MassConsumerEnvelopeCallback.php
@@ -0,0 +1,137 @@
+resource = $resource;
+ $this->messageController = $messageController;
+ $this->configuration = $configuration;
+ $this->operationProcessor = $operationProcessorFactory->create(
+ [
+ 'configuration' => $configuration
+ ]
+ );
+ $this->logger = $logger;
+ $this->queue = $queue;
+ }
+
+ /**
+ * Get transaction callback. This handles the case of async.
+ *
+ * @param EnvelopeInterface $message
+ * @return void
+ */
+ public function execute(EnvelopeInterface $message)
+ {
+ $queue = $this->queue;
+ /** @var LockInterface $lock */
+ $lock = null;
+ try {
+ $topicName = $message->getProperties()['topic_name'];
+ $lock = $this->messageController->lock($message, $this->configuration->getConsumerName());
+
+ $allowedTopics = $this->configuration->getTopicNames();
+ if (in_array($topicName, $allowedTopics)) {
+ $this->operationProcessor->process($message->getBody());
+ } else {
+ $queue->reject($message);
+ return;
+ }
+ $queue->acknowledge($message);
+ } catch (MessageLockException $exception) {
+ $queue->acknowledge($message);
+ } catch (ConnectionLostException $e) {
+ if ($lock) {
+ $this->resource->getConnection()
+ ->delete($this->resource->getTableName('queue_lock'), ['id = ?' => $lock->getId()]);
+ }
+ } catch (NotFoundException $e) {
+ $queue->acknowledge($message);
+ $this->logger->warning($e->getMessage());
+ } catch (\Exception $e) {
+ $queue->reject($message, false, $e->getMessage());
+ if ($lock) {
+ $this->resource->getConnection()
+ ->delete($this->resource->getTableName('queue_lock'), ['id = ?' => $lock->getId()]);
+ }
+ }
+ }
+
+ /**
+ * Get message queue.
+ *
+ * @return QueueInterface
+ */
+ public function getQueue()
+ {
+ return $this->queue;
+ }
+}
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/FullCaptureAuthorizenetAcceptjsTest.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/FullCaptureAuthorizenetAcceptjsTest.xml
index 42a78291436ed..6aa6792e0e0d4 100644
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/FullCaptureAuthorizenetAcceptjsTest.xml
+++ b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/FullCaptureAuthorizenetAcceptjsTest.xml
@@ -54,6 +54,7 @@
+
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/GuestCheckoutVirtualProductAuthorizenetAcceptjsTest.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/GuestCheckoutVirtualProductAuthorizenetAcceptjsTest.xml
index 95c2436905212..6f71bd180766f 100644
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/GuestCheckoutVirtualProductAuthorizenetAcceptjsTest.xml
+++ b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/GuestCheckoutVirtualProductAuthorizenetAcceptjsTest.xml
@@ -55,8 +55,10 @@
+
+
diff --git a/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php b/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php
index 50279786c0a5b..bca7f13b0cee3 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php
@@ -19,21 +19,21 @@ class Grid extends \Magento\Backend\Block\Dashboard\Grid
protected $_collectionFactory;
/**
- * @var \Magento\Framework\Module\Manager
+ * @var \Magento\Framework\Module\ModuleManagerInterface
*/
protected $_moduleManager;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Backend\Helper\Data $backendHelper
- * @param \Magento\Framework\Module\Manager $moduleManager
+ * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager
* @param \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Backend\Helper\Data $backendHelper,
- \Magento\Framework\Module\Manager $moduleManager,
+ \Magento\Framework\Module\ModuleManagerInterface $moduleManager,
\Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory,
array $data = []
) {
@@ -43,6 +43,8 @@ public function __construct(
}
/**
+ * Construct.
+ *
* @return void
*/
protected function _construct()
@@ -52,6 +54,8 @@ protected function _construct()
}
/**
+ * Prepare collection.
+ *
* @return $this
*/
protected function _prepareCollection()
@@ -110,6 +114,8 @@ protected function _preparePage()
}
/**
+ * Prepare columns.
+ *
* @return $this
*/
protected function _prepareColumns()
@@ -129,7 +135,9 @@ protected function _prepareColumns()
]
);
- $baseCurrencyCode = $this->_storeManager->getStore((int)$this->getParam('store'))->getBaseCurrencyCode();
+ $baseCurrencyCode = $this->_storeManager->getStore(
+ (int)$this->getParam('store')
+ )->getBaseCurrencyCode();
$this->addColumn(
'total',
@@ -149,7 +157,7 @@ protected function _prepareColumns()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getRowUrl($row)
{
diff --git a/app/code/Magento/Backend/Block/Dashboard/Sales.php b/app/code/Magento/Backend/Block/Dashboard/Sales.php
index 6d7a4d6458a8e..3455ff087a799 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Sales.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Sales.php
@@ -18,20 +18,20 @@ class Sales extends \Magento\Backend\Block\Dashboard\Bar
protected $_template = 'Magento_Backend::dashboard/salebar.phtml';
/**
- * @var \Magento\Framework\Module\Manager
+ * @var \Magento\Framework\Module\ModuleManagerInterface
*/
protected $_moduleManager;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory
- * @param \Magento\Framework\Module\Manager $moduleManager
+ * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory,
- \Magento\Framework\Module\Manager $moduleManager,
+ \Magento\Framework\Module\ModuleManagerInterface $moduleManager,
array $data = []
) {
$this->_moduleManager = $moduleManager;
@@ -39,6 +39,8 @@ public function __construct(
}
/**
+ * Prepare layout.
+ *
* @return $this|void
*/
protected function _prepareLayout()
diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php
index cac10ae372004..7dc897a62a320 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php
@@ -19,21 +19,21 @@ class Ordered extends \Magento\Backend\Block\Dashboard\Grid
protected $_collectionFactory;
/**
- * @var \Magento\Framework\Module\Manager
+ * @var \Magento\Framework\Module\ModuleManagerInterface
*/
protected $_moduleManager;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Backend\Helper\Data $backendHelper
- * @param \Magento\Framework\Module\Manager $moduleManager
+ * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager
* @param \Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory $collectionFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Backend\Helper\Data $backendHelper,
- \Magento\Framework\Module\Manager $moduleManager,
+ \Magento\Framework\Module\ModuleManagerInterface $moduleManager,
\Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory $collectionFactory,
array $data = []
) {
@@ -43,6 +43,8 @@ public function __construct(
}
/**
+ * Construct.
+ *
* @return void
*/
protected function _construct()
@@ -52,7 +54,7 @@ protected function _construct()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
protected function _prepareCollection()
{
@@ -81,7 +83,7 @@ protected function _prepareCollection()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
protected function _prepareColumns()
{
diff --git a/app/code/Magento/Backend/Block/Dashboard/Totals.php b/app/code/Magento/Backend/Block/Dashboard/Totals.php
index 4dcda3677584c..e57a6249af47d 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Totals.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Totals.php
@@ -11,6 +11,9 @@
*/
namespace Magento\Backend\Block\Dashboard;
+/**
+ * Totals block.
+ */
class Totals extends \Magento\Backend\Block\Dashboard\Bar
{
/**
@@ -19,20 +22,20 @@ class Totals extends \Magento\Backend\Block\Dashboard\Bar
protected $_template = 'Magento_Backend::dashboard/totalbar.phtml';
/**
- * @var \Magento\Framework\Module\Manager
+ * @var \Magento\Framework\Module\ModuleManagerInterface
*/
protected $_moduleManager;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory
- * @param \Magento\Framework\Module\Manager $moduleManager
+ * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory,
- \Magento\Framework\Module\Manager $moduleManager,
+ \Magento\Framework\Module\ModuleManagerInterface $moduleManager,
array $data = []
) {
$this->_moduleManager = $moduleManager;
@@ -40,6 +43,7 @@ public function __construct(
}
/**
+ * @inheritDoc
* @return $this|void
*/
protected function _prepareLayout()
diff --git a/app/code/Magento/Backend/Model/Menu/Item.php b/app/code/Magento/Backend/Model/Menu/Item.php
index 67c6216cbbc06..d535e9c84df24 100644
--- a/app/code/Magento/Backend/Model/Menu/Item.php
+++ b/app/code/Magento/Backend/Model/Menu/Item.php
@@ -145,7 +145,7 @@ class Item
protected $_moduleList;
/**
- * @var \Magento\Framework\Module\Manager
+ * @var \Magento\Framework\Module\ModuleManagerInterface
*/
private $_moduleManager;
@@ -163,7 +163,7 @@ class Item
* @param \Magento\Backend\Model\MenuFactory $menuFactory
* @param \Magento\Backend\Model\UrlInterface $urlModel
* @param \Magento\Framework\Module\ModuleListInterface $moduleList
- * @param \Magento\Framework\Module\Manager $moduleManager
+ * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager
* @param array $data
*/
public function __construct(
@@ -173,7 +173,7 @@ public function __construct(
\Magento\Backend\Model\MenuFactory $menuFactory,
\Magento\Backend\Model\UrlInterface $urlModel,
\Magento\Framework\Module\ModuleListInterface $moduleList,
- \Magento\Framework\Module\Manager $moduleManager,
+ \Magento\Framework\Module\ModuleManagerInterface $moduleManager,
array $data = []
) {
$this->_validator = $validator;
diff --git a/app/code/Magento/Backend/Model/Url.php b/app/code/Magento/Backend/Model/Url.php
index f199fd0fe7bf1..ba0c3d1cfacee 100644
--- a/app/code/Magento/Backend/Model/Url.php
+++ b/app/code/Magento/Backend/Model/Url.php
@@ -13,6 +13,7 @@
* Class \Magento\Backend\Model\UrlInterface
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
* @api
* @since 100.0.2
*/
@@ -366,6 +367,19 @@ protected function _getMenu()
return $this->_menu;
}
+ /**
+ * Set scope entity
+ *
+ * @param mixed $scopeId
+ * @return \Magento\Framework\UrlInterface
+ */
+ public function setScope($scopeId)
+ {
+ parent::setScope($scopeId);
+ $this->_scope = $this->_scopeResolver->getScope($scopeId);
+ return $this;
+ }
+
/**
* Set custom auth session
*
@@ -402,13 +416,13 @@ public function getAreaFrontName()
}
/**
- * Retrieve action path.
- * Add backend area front name as a prefix to action path
+ * Retrieve action path, add backend area front name as a prefix to action path
*
* @return string
*/
protected function _getActionPath()
{
+
$path = parent::_getActionPath();
if ($path) {
if ($this->getAreaFrontName()) {
@@ -448,8 +462,7 @@ protected function _getConfigCacheId($path)
}
/**
- * Get config data by path
- * Use only global config values for backend
+ * Get config data by path, use only global config values for backend
*
* @param string $path
* @return null|string
diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminSlideOutDialogSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminSlideOutDialogSection.xml
index a01e025ba3dca..2f799721a8cef 100644
--- a/app/code/Magento/Backend/Test/Mftf/Section/AdminSlideOutDialogSection.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminSlideOutDialogSection.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginAfterJSMinificationTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginAfterJSMinificationTest.xml
index d3b2916ee5825..38749dfd792ca 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginAfterJSMinificationTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginAfterJSMinificationTest.xml
@@ -18,6 +18,9 @@
+
+
+
diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/TextTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/TextTest.php
index 1bf23649e2ea8..5aa8cf7a0c579 100644
--- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/TextTest.php
+++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/TextTest.php
@@ -8,6 +8,9 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+/**
+ * Unit test for \Magento\Backend\Block\Widget\Grid\Column\Filter\Text
+ */
class TextTest extends \PHPUnit\Framework\TestCase
{
/** @var \Magento\Backend\Block\Widget\Grid\Column\Filter\Text*/
@@ -31,7 +34,10 @@ protected function setUp()
->setMethods(['getEscaper'])
->disableOriginalConstructor()
->getMock();
- $this->escaper = $this->createPartialMock(\Magento\Framework\Escaper::class, ['escapeHtml']);
+ $this->escaper = $this->createPartialMock(
+ \Magento\Framework\Escaper::class,
+ ['escapeHtml', 'escapeHtmlAttr']
+ );
$this->helper = $this->createMock(\Magento\Framework\DB\Helper::class);
$this->context->expects($this->once())->method('getEscaper')->willReturn($this->escaper);
@@ -60,6 +66,13 @@ public function testGetHtml()
$this->block->setColumn($column);
$this->escaper->expects($this->any())->method('escapeHtml')->willReturn('escapedHtml');
+ $this->escaper->expects($this->once())
+ ->method('escapeHtmlAttr')
+ ->willReturnCallback(
+ function ($string) {
+ return $string;
+ }
+ );
$column->expects($this->any())->method('getId')->willReturn('id');
$column->expects($this->once())->method('getHtmlId')->willReturn('htmlId');
diff --git a/app/code/Magento/Backend/view/adminhtml/templates/admin/access_denied.phtml b/app/code/Magento/Backend/view/adminhtml/templates/admin/access_denied.phtml
index 843328fbf17d7..be309423c48d2 100644
--- a/app/code/Magento/Backend/view/adminhtml/templates/admin/access_denied.phtml
+++ b/app/code/Magento/Backend/view/adminhtml/templates/admin/access_denied.phtml
@@ -3,14 +3,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
-// @codingStandardsIgnoreFile
-
?>
@@ -21,10 +20,10 @@
= $block->escapeHtml(__('Contact a system administrator or store owner to gain permissions.')) ?>
= $block->escapeHtml(__('Return to ')) ?>
-
+
= $block->escapeHtml(__('previous page')) ?>= $block->escapeHtml(__('.')) ?>
-
+
= $block->escapeHtml(__('previous page')) ?>= $block->escapeHtml(__('.')) ?>
diff --git a/app/code/Magento/Backend/view/adminhtml/templates/admin/formkey.phtml b/app/code/Magento/Backend/view/adminhtml/templates/admin/formkey.phtml
index 9629db9fa455b..edc14190e4edf 100644
--- a/app/code/Magento/Backend/view/adminhtml/templates/admin/formkey.phtml
+++ b/app/code/Magento/Backend/view/adminhtml/templates/admin/formkey.phtml
@@ -4,4 +4,4 @@
* See COPYING.txt for license details.
*/
?>
-
+
diff --git a/app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml b/app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml
index 52d5dd6d114ee..1d05450f44c99 100644
--- a/app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml
+++ b/app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml
@@ -4,19 +4,20 @@
* See COPYING.txt for license details.
*/
-// @codingStandardsIgnoreFile
-
+/**
+ * @var \Magento\Framework\View\Element\AbstractBlock $block
+ */
?>