From b7af8a5d6885fab20700544a786fa07a55c11a96 Mon Sep 17 00:00:00 2001 From: PromInc Date: Thu, 8 Jul 2021 09:42:46 -0500 Subject: [PATCH 01/41] Correctly label option for Protection Type The `Password Reset Protection Type` option `By IP and Email` is inaccurate as the function does and `OR` lookup, not an `AND`. --- app/code/Magento/Security/i18n/en_US.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Security/i18n/en_US.csv b/app/code/Magento/Security/i18n/en_US.csv index 3d5bb6e8b59d4..30da17885926b 100644 --- a/app/code/Magento/Security/i18n/en_US.csv +++ b/app/code/Magento/Security/i18n/en_US.csv @@ -5,7 +5,7 @@ "Your current session is terminated by another user of this account.","Your current session is terminated by another user of this account." "Your account is temporarily disabled.","Your account is temporarily disabled." "Your current session has been expired.","Your current session has been expired." -"By IP and Email","By IP and Email" +"By IP or Email","By IP or Email" "By IP","By IP" "By Email","By Email" None,None From 242c12fd7950e876ef6f2e06e8c2e47486a188af Mon Sep 17 00:00:00 2001 From: PromInc Date: Thu, 8 Jul 2021 09:44:05 -0500 Subject: [PATCH 02/41] Correctly label option for Protection Type The `Password Reset Protection Type` option `By IP and Email` is inaccurate as the function does and `OR` lookup, not an `AND`. --- .../Test/Unit/Model/Config/Source/ResetMethodTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php b/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php index 94b35e6e3f5e0..38d4d32097272 100644 --- a/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php @@ -41,8 +41,8 @@ public function testToOptionArray() { $expected = [ [ - 'value' => ResetMethod::OPTION_BY_IP_AND_EMAIL, - 'label' => __('By IP and Email') + 'value' => ResetMethod::OPTION_BY_IP_OR_EMAIL, + 'label' => __('By IP or Email') ], [ 'value' => ResetMethod::OPTION_BY_IP, @@ -63,7 +63,7 @@ public function testToOptionArray() public function testToArray() { $expected = [ - ResetMethod::OPTION_BY_IP_AND_EMAIL => __('By IP and Email'), + ResetMethod::OPTION_BY_IP_OR_EMAIL => __('By IP or Email'), ResetMethod::OPTION_BY_IP => __('By IP'), ResetMethod::OPTION_BY_EMAIL => __('By Email'), ResetMethod::OPTION_NONE => __('None'), From 08d20bed42ee51c4abf65f7b37171d46d1f807e0 Mon Sep 17 00:00:00 2001 From: PromInc Date: Thu, 8 Jul 2021 09:45:03 -0500 Subject: [PATCH 03/41] Correctly label option for Protection Type The `Password Reset Protection Type` option `By IP and Email` is inaccurate as the function does and `OR` lookup, not an `AND`. --- .../Test/Unit/Model/SecurityChecker/FrequencyTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/FrequencyTest.php b/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/FrequencyTest.php index 0d9b5c0f755dc..c4b50c0807fbf 100644 --- a/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/FrequencyTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/FrequencyTest.php @@ -179,7 +179,7 @@ public function dataProviderSecurityEventTypeWithRequestsMethod() return [ [ PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, - ResetMethod::OPTION_BY_IP_AND_EMAIL + ResetMethod::OPTION_BY_IP_OR_EMAIL ], [ PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, @@ -191,7 +191,7 @@ public function dataProviderSecurityEventTypeWithRequestsMethod() ], [ PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, - ResetMethod::OPTION_BY_IP_AND_EMAIL + ResetMethod::OPTION_BY_IP_OR_EMAIL ], [ PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, From 6c87486a3c24d766b674d5c576fce7299b61bf80 Mon Sep 17 00:00:00 2001 From: PromInc Date: Thu, 8 Jul 2021 09:45:44 -0500 Subject: [PATCH 04/41] Correctly label option for Protection Type The `Password Reset Protection Type` option `By IP and Email` is inaccurate as the function does and `OR` lookup, not an `AND`. --- .../Security/Test/Unit/Model/SecurityChecker/QuantityTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/QuantityTest.php b/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/QuantityTest.php index 5bdc5563ecc86..790dca9d5f551 100644 --- a/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/QuantityTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/QuantityTest.php @@ -147,7 +147,7 @@ public function dataProviderSecurityEventTypeWithRequestsMethod() return [ [ PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, - ResetMethod::OPTION_BY_IP_AND_EMAIL + ResetMethod::OPTION_BY_IP_OR_EMAIL ], [ PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, @@ -159,7 +159,7 @@ public function dataProviderSecurityEventTypeWithRequestsMethod() ], [ PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, - ResetMethod::OPTION_BY_IP_AND_EMAIL + ResetMethod::OPTION_BY_IP_OR_EMAIL ], [ PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, From 692f96da35aad52a0e8c068e698f7d9ecf3fb0f6 Mon Sep 17 00:00:00 2001 From: PromInc Date: Thu, 8 Jul 2021 09:46:55 -0500 Subject: [PATCH 05/41] Correctly label option for Protection Type The `Password Reset Protection Type` option `By IP and Email` is inaccurate as the function does and `OR` lookup, not an `AND`. --- .../PasswordResetRequestEvent/CollectionFactoryTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Security/Test/Unit/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactoryTest.php b/app/code/Magento/Security/Test/Unit/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactoryTest.php index 8b28489d5a867..f8a8dd4a744bb 100644 --- a/app/code/Magento/Security/Test/Unit/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactoryTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactoryTest.php @@ -82,7 +82,7 @@ public function testCreate( ->method('filterByIp') ->with($longIp); } - if ($limitMethod == ResetMethod::OPTION_BY_IP_AND_EMAIL) { + if ($limitMethod == ResetMethod::OPTION_BY_IP_OR_EMAIL) { $collectionMcok->expects($this->once()) ->method('filterByIpOrAccountReference') ->with($longIp, $accountReference); @@ -99,7 +99,7 @@ public function createDataProvider() [null], [ResetMethod::OPTION_BY_EMAIL, 1, 'accountReference'], [ResetMethod::OPTION_BY_IP, 1, null, 'longIp'], - [ResetMethod::OPTION_BY_IP_AND_EMAIL, 1, 'accountReference', 'longIp'], + [ResetMethod::OPTION_BY_IP_OR_EMAIL, 1, 'accountReference', 'longIp'], ]; } } From 4febd7cd9a231ae3b43d42de6d3a2bde8cecd7cc Mon Sep 17 00:00:00 2001 From: PromInc Date: Thu, 8 Jul 2021 09:47:22 -0500 Subject: [PATCH 06/41] Correctly label option for Protection Type The `Password Reset Protection Type` option `By IP and Email` is inaccurate as the function does and `OR` lookup, not an `AND`. --- .../Magento/Security/Test/Unit/Model/SecurityManagerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Security/Test/Unit/Model/SecurityManagerTest.php b/app/code/Magento/Security/Test/Unit/Model/SecurityManagerTest.php index ec69ac40c0188..c6481387e6eda 100644 --- a/app/code/Magento/Security/Test/Unit/Model/SecurityManagerTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/SecurityManagerTest.php @@ -161,7 +161,7 @@ public function testConstructorException() public function testPerformSecurityCheck() { $requestType = PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST; - $accountReference = ResetMethod::OPTION_BY_IP_AND_EMAIL; + $accountReference = ResetMethod::OPTION_BY_IP_OR_EMAIL; $longIp = 12345; $this->remoteAddressMock->expects($this->once()) From 41188dbf8c90bddfa45117cfe61734fc32912bb3 Mon Sep 17 00:00:00 2001 From: PromInc Date: Thu, 8 Jul 2021 09:48:41 -0500 Subject: [PATCH 07/41] Correctly label option for Protection Type The `Password Reset Protection Type` option `By IP and Email` is inaccurate as the function does and `OR` lookup, not an `AND`. --- .../Magento/Security/Model/Config/Source/ResetMethod.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Security/Model/Config/Source/ResetMethod.php b/app/code/Magento/Security/Model/Config/Source/ResetMethod.php index b925262747fd0..577a5d26b2c38 100644 --- a/app/code/Magento/Security/Model/Config/Source/ResetMethod.php +++ b/app/code/Magento/Security/Model/Config/Source/ResetMethod.php @@ -12,7 +12,7 @@ */ class ResetMethod implements \Magento\Framework\Option\ArrayInterface { - const OPTION_BY_IP_AND_EMAIL = 1; + const OPTION_BY_IP_OR_EMAIL = 1; const OPTION_BY_IP = 2; const OPTION_BY_EMAIL = 3; const OPTION_NONE = 0; @@ -25,7 +25,7 @@ class ResetMethod implements \Magento\Framework\Option\ArrayInterface public function toOptionArray() { return [ - ['value' => self::OPTION_BY_IP_AND_EMAIL, 'label' => __('By IP and Email')], + ['value' => self::OPTION_BY_IP_OR_EMAIL, 'label' => __('By IP or Email')], ['value' => self::OPTION_BY_IP, 'label' => __('By IP')], ['value' => self::OPTION_BY_EMAIL, 'label' => __('By Email')], ['value' => self::OPTION_NONE, 'label' => __('None')], @@ -40,7 +40,7 @@ public function toOptionArray() public function toArray() { return [ - self::OPTION_BY_IP_AND_EMAIL => __('By IP and Email'), + self::OPTION_BY_IP_OR_EMAIL => __('By IP or Email'), self::OPTION_BY_IP => __('By IP'), self::OPTION_BY_EMAIL => __('By Email'), self::OPTION_NONE => __('None'), From bf1c3408c2b26bf32455180bad2a726d0d677c2e Mon Sep 17 00:00:00 2001 From: PromInc Date: Thu, 8 Jul 2021 09:49:14 -0500 Subject: [PATCH 08/41] Correctly label option for Protection Type The `Password Reset Protection Type` option `By IP and Email` is inaccurate as the function does and `OR` lookup, not an `AND`. --- .../PasswordResetRequestEvent/CollectionFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Security/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactory.php b/app/code/Magento/Security/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactory.php index 910441399d29a..79a3611a9de8a 100644 --- a/app/code/Magento/Security/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactory.php +++ b/app/code/Magento/Security/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactory.php @@ -81,7 +81,7 @@ public function create( case ResetMethod::OPTION_BY_IP: $collection->filterByIp($longIp); break; - case ResetMethod::OPTION_BY_IP_AND_EMAIL: + case ResetMethod::OPTION_BY_IP_OR_EMAIL: $collection->filterByIpOrAccountReference($longIp, $accountReference); break; default: From ba24475d776d75886ac0b1df07f8d565d1ccb6ae Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 11 Oct 2021 11:49:51 -0500 Subject: [PATCH 09/41] Sort by timestamp and id When time stamps are equal, sort by `entity_id`. Technically speaking this isn't perfect as well as the `entity_id`'s could come from different record sources (ie. comments and invoices). But given that they were at the exact same time this is acceptable. This at least ensures that the records from the same table are sorted accurately. --- .../Sales/Block/Adminhtml/Order/View/Tab/History.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php index 0972d74314246..0eca73f91e355 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php @@ -76,6 +76,7 @@ public function getFullHistory() $history = []; foreach ($order->getAllStatusHistory() as $orderComment) { $history[] = $this->_prepareHistoryItem( + $orderComment->getId(), $orderComment->getStatusLabel(), $orderComment->getIsCustomerNotified(), $this->getOrderAdminDate($orderComment->getCreatedAt()), @@ -85,6 +86,7 @@ public function getFullHistory() foreach ($order->getCreditmemosCollection() as $_memo) { $history[] = $this->_prepareHistoryItem( + $_memo->getId(), __('Credit memo #%1 created', $_memo->getIncrementId()), $_memo->getEmailSent(), $this->getOrderAdminDate($_memo->getCreatedAt()) @@ -92,6 +94,7 @@ public function getFullHistory() foreach ($_memo->getCommentsCollection() as $_comment) { $history[] = $this->_prepareHistoryItem( + $_comment->getId(), __('Credit memo #%1 comment added', $_memo->getIncrementId()), $_comment->getIsCustomerNotified(), $this->getOrderAdminDate($_comment->getCreatedAt()), @@ -102,6 +105,7 @@ public function getFullHistory() foreach ($order->getShipmentsCollection() as $_shipment) { $history[] = $this->_prepareHistoryItem( + $_shipment->getId(), __('Shipment #%1 created', $_shipment->getIncrementId()), $_shipment->getEmailSent(), $this->getOrderAdminDate($_shipment->getCreatedAt()) @@ -109,6 +113,7 @@ public function getFullHistory() foreach ($_shipment->getCommentsCollection() as $_comment) { $history[] = $this->_prepareHistoryItem( + $_comment->getId(), __('Shipment #%1 comment added', $_shipment->getIncrementId()), $_comment->getIsCustomerNotified(), $this->getOrderAdminDate($_comment->getCreatedAt()), @@ -119,6 +124,7 @@ public function getFullHistory() foreach ($order->getInvoiceCollection() as $_invoice) { $history[] = $this->_prepareHistoryItem( + $_invoice->getId(), __('Invoice #%1 created', $_invoice->getIncrementId()), $_invoice->getEmailSent(), $this->getOrderAdminDate($_invoice->getCreatedAt()) @@ -126,6 +132,7 @@ public function getFullHistory() foreach ($_invoice->getCommentsCollection() as $_comment) { $history[] = $this->_prepareHistoryItem( + $_comment->getId(), __('Invoice #%1 comment added', $_invoice->getIncrementId()), $_comment->getIsCustomerNotified(), $this->getOrderAdminDate($_comment->getCreatedAt()), @@ -136,6 +143,7 @@ public function getFullHistory() foreach ($order->getTracksCollection() as $_track) { $history[] = $this->_prepareHistoryItem( + $_track->getId(), __('Tracking number %1 for %2 assigned', $_track->getNumber(), $_track->getTitle()), false, $this->getOrderAdminDate($_track->getCreatedAt()) @@ -303,6 +311,10 @@ public static function sortHistoryByTimestamp($a, $b) { $createdAtA = $a['created_at']; $createdAtB = $b['created_at']; + + if( $createdAtA->getTimestamp() === $createdAtB->getTimestamp() ) { + return $a['entity_id'] <=> $b['entity_id']; + } return $createdAtA->getTimestamp() <=> $createdAtB->getTimestamp(); } From eba21cf905ddcc6fb91629d792ab3984dc6aa58f Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 11 Oct 2021 11:56:54 -0500 Subject: [PATCH 10/41] Update ResetMethod.php --- app/code/Magento/Security/Model/Config/Source/ResetMethod.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Security/Model/Config/Source/ResetMethod.php b/app/code/Magento/Security/Model/Config/Source/ResetMethod.php index 577a5d26b2c38..2cc98e96fbfef 100644 --- a/app/code/Magento/Security/Model/Config/Source/ResetMethod.php +++ b/app/code/Magento/Security/Model/Config/Source/ResetMethod.php @@ -25,7 +25,7 @@ class ResetMethod implements \Magento\Framework\Option\ArrayInterface public function toOptionArray() { return [ - ['value' => self::OPTION_BY_IP_OR_EMAIL, 'label' => __('By IP or Email')], + ['value' => self::OPTION_BY_IP_AND_EMAIL, 'label' => __('By IP and Email')], ['value' => self::OPTION_BY_IP, 'label' => __('By IP')], ['value' => self::OPTION_BY_EMAIL, 'label' => __('By Email')], ['value' => self::OPTION_NONE, 'label' => __('None')], @@ -40,7 +40,7 @@ public function toOptionArray() public function toArray() { return [ - self::OPTION_BY_IP_OR_EMAIL => __('By IP or Email'), + self::OPTION_BY_IP_AND_EMAIL => __('By IP and Email'), self::OPTION_BY_IP => __('By IP'), self::OPTION_BY_EMAIL => __('By Email'), self::OPTION_NONE => __('None'), From 7947440921195e710052e5d7ba579f2e7e633e2b Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 11 Oct 2021 11:57:13 -0500 Subject: [PATCH 11/41] Update ResetMethod.php --- app/code/Magento/Security/Model/Config/Source/ResetMethod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Security/Model/Config/Source/ResetMethod.php b/app/code/Magento/Security/Model/Config/Source/ResetMethod.php index 2cc98e96fbfef..b925262747fd0 100644 --- a/app/code/Magento/Security/Model/Config/Source/ResetMethod.php +++ b/app/code/Magento/Security/Model/Config/Source/ResetMethod.php @@ -12,7 +12,7 @@ */ class ResetMethod implements \Magento\Framework\Option\ArrayInterface { - const OPTION_BY_IP_OR_EMAIL = 1; + const OPTION_BY_IP_AND_EMAIL = 1; const OPTION_BY_IP = 2; const OPTION_BY_EMAIL = 3; const OPTION_NONE = 0; From 36a2245f51c8ef5ee839c42ad439d6b355113feb Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 11 Oct 2021 11:57:34 -0500 Subject: [PATCH 12/41] Update CollectionFactory.php --- .../PasswordResetRequestEvent/CollectionFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Security/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactory.php b/app/code/Magento/Security/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactory.php index 79a3611a9de8a..910441399d29a 100644 --- a/app/code/Magento/Security/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactory.php +++ b/app/code/Magento/Security/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactory.php @@ -81,7 +81,7 @@ public function create( case ResetMethod::OPTION_BY_IP: $collection->filterByIp($longIp); break; - case ResetMethod::OPTION_BY_IP_OR_EMAIL: + case ResetMethod::OPTION_BY_IP_AND_EMAIL: $collection->filterByIpOrAccountReference($longIp, $accountReference); break; default: From e46991f81ed1c694ecef1515c139b211ee6401b8 Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 11 Oct 2021 11:57:51 -0500 Subject: [PATCH 13/41] Update ResetMethodTest.php --- .../Test/Unit/Model/Config/Source/ResetMethodTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php b/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php index 38d4d32097272..b3db54546eabf 100644 --- a/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php @@ -41,8 +41,8 @@ public function testToOptionArray() { $expected = [ [ - 'value' => ResetMethod::OPTION_BY_IP_OR_EMAIL, - 'label' => __('By IP or Email') + 'value' => ResetMethod::OPTION_BY_IP_AND_EMAIL, + 'label' => __('By IP and Email') ], [ 'value' => ResetMethod::OPTION_BY_IP, From 81e3cbc97c6ddb0991a4cc274317103942aab02c Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 11 Oct 2021 11:58:23 -0500 Subject: [PATCH 14/41] Update ResetMethodTest.php --- .../Security/Test/Unit/Model/Config/Source/ResetMethodTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php b/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php index b3db54546eabf..7d9da1e4cfe23 100644 --- a/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php @@ -63,7 +63,7 @@ public function testToOptionArray() public function testToArray() { $expected = [ - ResetMethod::OPTION_BY_IP_OR_EMAIL => __('By IP or Email'), + ResetMethod::OPTION_BY_IP_AND_EMAIL => __('By IP and Email'), ResetMethod::OPTION_BY_IP => __('By IP'), ResetMethod::OPTION_BY_EMAIL => __('By Email'), ResetMethod::OPTION_NONE => __('None'), From c1fb73c22bc088938a045f6dba0c05b17cbc768e Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 11 Oct 2021 11:58:46 -0500 Subject: [PATCH 15/41] Update CollectionFactoryTest.php --- .../PasswordResetRequestEvent/CollectionFactoryTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Security/Test/Unit/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactoryTest.php b/app/code/Magento/Security/Test/Unit/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactoryTest.php index f8a8dd4a744bb..8b28489d5a867 100644 --- a/app/code/Magento/Security/Test/Unit/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactoryTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/ResourceModel/PasswordResetRequestEvent/CollectionFactoryTest.php @@ -82,7 +82,7 @@ public function testCreate( ->method('filterByIp') ->with($longIp); } - if ($limitMethod == ResetMethod::OPTION_BY_IP_OR_EMAIL) { + if ($limitMethod == ResetMethod::OPTION_BY_IP_AND_EMAIL) { $collectionMcok->expects($this->once()) ->method('filterByIpOrAccountReference') ->with($longIp, $accountReference); @@ -99,7 +99,7 @@ public function createDataProvider() [null], [ResetMethod::OPTION_BY_EMAIL, 1, 'accountReference'], [ResetMethod::OPTION_BY_IP, 1, null, 'longIp'], - [ResetMethod::OPTION_BY_IP_OR_EMAIL, 1, 'accountReference', 'longIp'], + [ResetMethod::OPTION_BY_IP_AND_EMAIL, 1, 'accountReference', 'longIp'], ]; } } From 5174e502a7c68a2db855a2ba8c21973ae9d0e88d Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 11 Oct 2021 11:59:19 -0500 Subject: [PATCH 16/41] Update FrequencyTest.php --- .../Test/Unit/Model/SecurityChecker/FrequencyTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/FrequencyTest.php b/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/FrequencyTest.php index c4b50c0807fbf..0d9b5c0f755dc 100644 --- a/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/FrequencyTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/FrequencyTest.php @@ -179,7 +179,7 @@ public function dataProviderSecurityEventTypeWithRequestsMethod() return [ [ PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, - ResetMethod::OPTION_BY_IP_OR_EMAIL + ResetMethod::OPTION_BY_IP_AND_EMAIL ], [ PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, @@ -191,7 +191,7 @@ public function dataProviderSecurityEventTypeWithRequestsMethod() ], [ PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, - ResetMethod::OPTION_BY_IP_OR_EMAIL + ResetMethod::OPTION_BY_IP_AND_EMAIL ], [ PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, From c81212c1d313faf4457e39e50bee842f0aa565f4 Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 11 Oct 2021 11:59:42 -0500 Subject: [PATCH 17/41] Update QuantityTest.php --- .../Security/Test/Unit/Model/SecurityChecker/QuantityTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/QuantityTest.php b/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/QuantityTest.php index 790dca9d5f551..5bdc5563ecc86 100644 --- a/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/QuantityTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/SecurityChecker/QuantityTest.php @@ -147,7 +147,7 @@ public function dataProviderSecurityEventTypeWithRequestsMethod() return [ [ PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, - ResetMethod::OPTION_BY_IP_OR_EMAIL + ResetMethod::OPTION_BY_IP_AND_EMAIL ], [ PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, @@ -159,7 +159,7 @@ public function dataProviderSecurityEventTypeWithRequestsMethod() ], [ PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, - ResetMethod::OPTION_BY_IP_OR_EMAIL + ResetMethod::OPTION_BY_IP_AND_EMAIL ], [ PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, From 75999e012b6cbb7a9b5909f655a78c67f63e5c38 Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 11 Oct 2021 11:59:58 -0500 Subject: [PATCH 18/41] Update SecurityManagerTest.php --- .../Magento/Security/Test/Unit/Model/SecurityManagerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Security/Test/Unit/Model/SecurityManagerTest.php b/app/code/Magento/Security/Test/Unit/Model/SecurityManagerTest.php index c6481387e6eda..ec69ac40c0188 100644 --- a/app/code/Magento/Security/Test/Unit/Model/SecurityManagerTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/SecurityManagerTest.php @@ -161,7 +161,7 @@ public function testConstructorException() public function testPerformSecurityCheck() { $requestType = PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST; - $accountReference = ResetMethod::OPTION_BY_IP_OR_EMAIL; + $accountReference = ResetMethod::OPTION_BY_IP_AND_EMAIL; $longIp = 12345; $this->remoteAddressMock->expects($this->once()) From 47e17a5209ec6719f58eac6146aafd4d91e1cd56 Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 11 Oct 2021 12:00:16 -0500 Subject: [PATCH 19/41] Update en_US.csv --- app/code/Magento/Security/i18n/en_US.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Security/i18n/en_US.csv b/app/code/Magento/Security/i18n/en_US.csv index 30da17885926b..3d5bb6e8b59d4 100644 --- a/app/code/Magento/Security/i18n/en_US.csv +++ b/app/code/Magento/Security/i18n/en_US.csv @@ -5,7 +5,7 @@ "Your current session is terminated by another user of this account.","Your current session is terminated by another user of this account." "Your account is temporarily disabled.","Your account is temporarily disabled." "Your current session has been expired.","Your current session has been expired." -"By IP or Email","By IP or Email" +"By IP and Email","By IP and Email" "By IP","By IP" "By Email","By Email" None,None From 1875102953ccfd2ae3b873093e7441afc5e6a243 Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 11 Oct 2021 12:00:38 -0500 Subject: [PATCH 20/41] Update ResetMethodTest.php --- .../Security/Test/Unit/Model/Config/Source/ResetMethodTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php b/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php index 7d9da1e4cfe23..94b35e6e3f5e0 100644 --- a/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/Config/Source/ResetMethodTest.php @@ -63,7 +63,7 @@ public function testToOptionArray() public function testToArray() { $expected = [ - ResetMethod::OPTION_BY_IP_AND_EMAIL => __('By IP and Email'), + ResetMethod::OPTION_BY_IP_AND_EMAIL => __('By IP and Email'), ResetMethod::OPTION_BY_IP => __('By IP'), ResetMethod::OPTION_BY_EMAIL => __('By Email'), ResetMethod::OPTION_NONE => __('None'), From f597b7a05eac0d3ff243492376f7924e32beacf7 Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 11 Oct 2021 14:05:11 -0500 Subject: [PATCH 21/41] Force invoices to be after other records Force invoices to go after other records. Since the IDs don't correlate (different sources) they needed to be forced after the order was made. --- .../Sales/Block/Adminhtml/Order/View/Tab/History.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php index 0eca73f91e355..417ce7aa0e90a 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php @@ -127,7 +127,8 @@ public function getFullHistory() $_invoice->getId(), __('Invoice #%1 created', $_invoice->getIncrementId()), $_invoice->getEmailSent(), - $this->getOrderAdminDate($_invoice->getCreatedAt()) + $this->getOrderAdminDate($_invoice->getCreatedAt()), + 'Invoice created' ); foreach ($_invoice->getCommentsCollection() as $_comment) { @@ -313,6 +314,9 @@ public static function sortHistoryByTimestamp($a, $b) $createdAtB = $b['created_at']; if( $createdAtA->getTimestamp() === $createdAtB->getTimestamp() ) { + if( $a['comment'] == 'Invoice created' || $b['comment'] == 'Invoice created' ) { + return ( $a['comment'] == 'Invoice created' ? 1 : -1 ); + } return $a['entity_id'] <=> $b['entity_id']; } From 6e79dc6d55a70f3a74ed4c64e6f2fa8a6ac396e6 Mon Sep 17 00:00:00 2001 From: PromInc Date: Tue, 12 Oct 2021 08:05:29 -0500 Subject: [PATCH 22/41] Update app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php Co-authored-by: Ihor Sviziev --- .../Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php index 417ce7aa0e90a..1763d879d3558 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php @@ -313,7 +313,7 @@ public static function sortHistoryByTimestamp($a, $b) $createdAtA = $a['created_at']; $createdAtB = $b['created_at']; - if( $createdAtA->getTimestamp() === $createdAtB->getTimestamp() ) { + if ($createdAtA->getTimestamp() === $createdAtB->getTimestamp()) { if( $a['comment'] == 'Invoice created' || $b['comment'] == 'Invoice created' ) { return ( $a['comment'] == 'Invoice created' ? 1 : -1 ); } From a5b81c2267aee989e404849ea3b919010c2f3f03 Mon Sep 17 00:00:00 2001 From: PromInc Date: Sun, 7 Nov 2021 21:51:29 -0600 Subject: [PATCH 23/41] Add type for sorting Added a new function for preparing that accounts for ID and type. The type is accounted into the sorting methods now. A new function for sorting is added since we are now sorting by more than timestamp. --- .../Adminhtml/Order/View/Tab/History.php | 98 +++++++++++++++---- 1 file changed, 78 insertions(+), 20 deletions(-) diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php index 1763d879d3558..5afef567e33ed 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php @@ -13,6 +13,15 @@ */ class History extends \Magento\Backend\Block\Template implements \Magento\Backend\Block\Widget\Tab\TabInterface { + private const HISTORY_TYPE_INVOICE = 1; + private const HISTORY_TYPE_INVOICE_COMMENT = 2; + private const HISTORY_TYPE_ORDER = 3; + private const HISTORY_TYPE_CREDIT_MEMO = 4; + private const HISTORY_TYPE_CREDIT_MEMO_COMMENT = 5; + private const HISTORY_TYPE_SHIPMENT = 6; + private const HISTORY_TYPE_SHIPMENT_COMMENT = 7; + private const HISTORY_TYPE_TRACKING_NUM = 8; + /** * Template * @@ -75,83 +84,93 @@ public function getFullHistory() $history = []; foreach ($order->getAllStatusHistory() as $orderComment) { - $history[] = $this->_prepareHistoryItem( + $history[] = $this->_prepareHistoryItemWithId( $orderComment->getId(), $orderComment->getStatusLabel(), $orderComment->getIsCustomerNotified(), $this->getOrderAdminDate($orderComment->getCreatedAt()), - $orderComment->getComment() + $orderComment->getComment(), + self::HISTORY_TYPE_ORDER ); } foreach ($order->getCreditmemosCollection() as $_memo) { - $history[] = $this->_prepareHistoryItem( + $history[] = $this->_prepareHistoryItemWithId( $_memo->getId(), __('Credit memo #%1 created', $_memo->getIncrementId()), $_memo->getEmailSent(), - $this->getOrderAdminDate($_memo->getCreatedAt()) + $this->getOrderAdminDate($_memo->getCreatedAt()), + 'Credit memo created', + self::HISTORY_TYPE_CREDIT_MEMO ); foreach ($_memo->getCommentsCollection() as $_comment) { - $history[] = $this->_prepareHistoryItem( + $history[] = $this->_prepareHistoryItemWithId( $_comment->getId(), __('Credit memo #%1 comment added', $_memo->getIncrementId()), $_comment->getIsCustomerNotified(), $this->getOrderAdminDate($_comment->getCreatedAt()), - $_comment->getComment() + $_comment->getComment(), + self::HISTORY_TYPE_CREDIT_MEMO_COMMENT ); } } foreach ($order->getShipmentsCollection() as $_shipment) { - $history[] = $this->_prepareHistoryItem( + $history[] = $this->_prepareHistoryItemWithId( $_shipment->getId(), __('Shipment #%1 created', $_shipment->getIncrementId()), $_shipment->getEmailSent(), - $this->getOrderAdminDate($_shipment->getCreatedAt()) + $this->getOrderAdminDate($_shipment->getCreatedAt()), + self::HISTORY_TYPE_SHIPMENT ); foreach ($_shipment->getCommentsCollection() as $_comment) { - $history[] = $this->_prepareHistoryItem( + $history[] = $this->_prepareHistoryItemWithId( $_comment->getId(), __('Shipment #%1 comment added', $_shipment->getIncrementId()), $_comment->getIsCustomerNotified(), $this->getOrderAdminDate($_comment->getCreatedAt()), - $_comment->getComment() + $_comment->getComment(), + self::HISTORY_TYPE_SHIPMENT_COMMENT ); } } foreach ($order->getInvoiceCollection() as $_invoice) { - $history[] = $this->_prepareHistoryItem( + $history[] = $this->_prepareHistoryItemWithId( $_invoice->getId(), __('Invoice #%1 created', $_invoice->getIncrementId()), $_invoice->getEmailSent(), $this->getOrderAdminDate($_invoice->getCreatedAt()), - 'Invoice created' + 'Invoice created', + self::HISTORY_TYPE_INVOICE ); foreach ($_invoice->getCommentsCollection() as $_comment) { - $history[] = $this->_prepareHistoryItem( + $history[] = $this->_prepareHistoryItemWithId( $_comment->getId(), __('Invoice #%1 comment added', $_invoice->getIncrementId()), $_comment->getIsCustomerNotified(), $this->getOrderAdminDate($_comment->getCreatedAt()), - $_comment->getComment() + $_comment->getComment(), + self::HISTORY_TYPE_INVOICE_COMMENT ); } } foreach ($order->getTracksCollection() as $_track) { - $history[] = $this->_prepareHistoryItem( + $history[] = $this->_prepareHistoryItemWithId( $_track->getId(), __('Tracking number %1 for %2 assigned', $_track->getNumber(), $_track->getTitle()), false, - $this->getOrderAdminDate($_track->getCreatedAt()) + $this->getOrderAdminDate($_track->getCreatedAt()), + 'Tracking number assigned', + self::HISTORY_TYPE_TRACKING_NUM ); } - usort($history, [__CLASS__, 'sortHistoryByTimestamp']); + usort($history, [__CLASS__, 'sortHistory']); return $history; } @@ -220,6 +239,7 @@ public function getItemComment(array $item) * @param bool $notified * @param \DateTimeInterface $created * @param string $comment + * @param int $type * @return array */ protected function _prepareHistoryItem($label, $notified, $created, $comment = '') @@ -227,6 +247,22 @@ protected function _prepareHistoryItem($label, $notified, $created, $comment = ' return ['title' => $label, 'notified' => $notified, 'comment' => $comment, 'created_at' => $created]; } + /** + * Map history items as array with id and type + * + * @param int $id + * @param string $label + * @param bool $notified + * @param \DateTimeInterface $created + * @param string $comment + * @param int $type + * @return array + */ + protected function _prepareHistoryItemWithId($id, $label, $notified, $created, $comment = '', $type = 0) + { + return ['entity_id' => $id, 'title' => $label, 'notified' => $notified, 'comment' => $comment, 'created_at' => $created, 'type' => $type]; + } + /** * @inheritdoc */ @@ -314,15 +350,37 @@ public static function sortHistoryByTimestamp($a, $b) $createdAtB = $b['created_at']; if ($createdAtA->getTimestamp() === $createdAtB->getTimestamp()) { - if( $a['comment'] == 'Invoice created' || $b['comment'] == 'Invoice created' ) { - return ( $a['comment'] == 'Invoice created' ? 1 : -1 ); - } return $a['entity_id'] <=> $b['entity_id']; } return $createdAtA->getTimestamp() <=> $createdAtB->getTimestamp(); } + /** + * Comparison For Sorting History By Timestamp and entity_id + * + * @param mixed $a + * @param mixed $b + * @return int + */ + private function sortHistory($a, $b) + { + $createdAtA = $a['created_at']; + $createdAtB = $b['created_at']; + + if ($createdAtA->getTimestamp() === $createdAtB->getTimestamp()) { + if ($a['type'] < $b['type']) { + return 1; + } elseif ($a['type'] > $b['type']) { + return -1; + } else { + return $a['entity_id'] <=> $b['entity_id']; + } + } + + return $createdAtA->getTimestamp() <=> $createdAtB->getTimestamp(); + } + /** * Get order admin date * From a23b4630fe2aaf9b3f6cb2d7277a1d67b0bbad3a Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 8 Nov 2021 21:18:25 -0600 Subject: [PATCH 24/41] Update app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php Co-authored-by: Ihor Sviziev --- .../Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php index 5afef567e33ed..47aa077cbd4ea 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php @@ -359,8 +359,8 @@ public static function sortHistoryByTimestamp($a, $b) /** * Comparison For Sorting History By Timestamp and entity_id * - * @param mixed $a - * @param mixed $b + * @param array $a + * @param array $b * @return int */ private function sortHistory($a, $b) From 70cf0a483f95e3837f1d31dc262869f9d3fc99bc Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 8 Nov 2021 21:27:45 -0600 Subject: [PATCH 25/41] Update app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php Co-authored-by: Ihor Sviziev --- .../Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php index 47aa077cbd4ea..a101ad02674f5 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php @@ -348,10 +348,6 @@ public static function sortHistoryByTimestamp($a, $b) { $createdAtA = $a['created_at']; $createdAtB = $b['created_at']; - - if ($createdAtA->getTimestamp() === $createdAtB->getTimestamp()) { - return $a['entity_id'] <=> $b['entity_id']; - } return $createdAtA->getTimestamp() <=> $createdAtB->getTimestamp(); } From 4109ff2cfd1a23f70be367176f48280c9658926c Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 8 Nov 2021 21:27:57 -0600 Subject: [PATCH 26/41] Update app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php Co-authored-by: Ihor Sviziev --- .../Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php index a101ad02674f5..24ad2c345f21c 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php @@ -359,7 +359,7 @@ public static function sortHistoryByTimestamp($a, $b) * @param array $b * @return int */ - private function sortHistory($a, $b) + private function sortHistory(array $a, array $b): int { $createdAtA = $a['created_at']; $createdAtB = $b['created_at']; From d4c0ba5680698ac002c5c9907982d81a5be2b7a7 Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 8 Nov 2021 21:30:03 -0600 Subject: [PATCH 27/41] define arguments --- .../Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php index 24ad2c345f21c..aaba107c59008 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php @@ -258,7 +258,7 @@ protected function _prepareHistoryItem($label, $notified, $created, $comment = ' * @param int $type * @return array */ - protected function _prepareHistoryItemWithId($id, $label, $notified, $created, $comment = '', $type = 0) + private function _prepareHistoryItemWithId(int $id, string $label, bool $notified, \DateTimeInterface $created, string $comment = '', int $type = 0): array { return ['entity_id' => $id, 'title' => $label, 'notified' => $notified, 'comment' => $comment, 'created_at' => $created, 'type' => $type]; } From 1e8d5c65a386af5a50c9479f014c4eb85525bf09 Mon Sep 17 00:00:00 2001 From: PromInc Date: Mon, 8 Nov 2021 21:44:04 -0600 Subject: [PATCH 28/41] Update app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php Co-authored-by: Ihor Sviziev --- .../Adminhtml/Order/View/Tab/History.php | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php index aaba107c59008..b6f19916b884e 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php @@ -361,20 +361,17 @@ public static function sortHistoryByTimestamp($a, $b) */ private function sortHistory(array $a, array $b): int { - $createdAtA = $a['created_at']; - $createdAtB = $b['created_at']; + $result = $this->sortHistoryByTimestamp($a, $b); + if (0 !== $result) { + return $result; + } - if ($createdAtA->getTimestamp() === $createdAtB->getTimestamp()) { - if ($a['type'] < $b['type']) { - return 1; - } elseif ($a['type'] > $b['type']) { - return -1; - } else { - return $a['entity_id'] <=> $b['entity_id']; - } + $result = $a['type'] <=> $b['type']; + if (0 !== $result) { + return $result; } - - return $createdAtA->getTimestamp() <=> $createdAtB->getTimestamp(); + + return $a['entity_id'] <=> $b['entity_id']; } /** From 284dad830dc0d5615b83ad1d25ebda684e62b15d Mon Sep 17 00:00:00 2001 From: engcom-Lima Date: Tue, 14 Dec 2021 10:46:16 +0530 Subject: [PATCH 29/41] [BUGFIX] - Fixed static test failures --- .../Adminhtml/Order/View/Tab/History.php | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php index b6f19916b884e..a69423e319b07 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php @@ -239,7 +239,6 @@ public function getItemComment(array $item) * @param bool $notified * @param \DateTimeInterface $created * @param string $comment - * @param int $type * @return array */ protected function _prepareHistoryItem($label, $notified, $created, $comment = '') @@ -258,11 +257,24 @@ protected function _prepareHistoryItem($label, $notified, $created, $comment = ' * @param int $type * @return array */ - private function _prepareHistoryItemWithId(int $id, string $label, bool $notified, \DateTimeInterface $created, string $comment = '', int $type = 0): array - { - return ['entity_id' => $id, 'title' => $label, 'notified' => $notified, 'comment' => $comment, 'created_at' => $created, 'type' => $type]; + private function _prepareHistoryItemWithId( + int $id, + string $label, + bool $notified, + \DateTimeInterface $created, + string $comment = '', + int $type = 0 + ): array { + return [ + 'entity_id' => $id, + 'title' => $label, + 'notified' => $notified, + 'comment' => $comment, + 'created_at' => $created, + 'type' => $type + ]; } - + /** * @inheritdoc */ @@ -358,22 +370,22 @@ public static function sortHistoryByTimestamp($a, $b) * @param array $a * @param array $b * @return int - */ + */ private function sortHistory(array $a, array $b): int { $result = $this->sortHistoryByTimestamp($a, $b); if (0 !== $result) { return $result; } - + $result = $a['type'] <=> $b['type']; if (0 !== $result) { return $result; } - + return $a['entity_id'] <=> $b['entity_id']; } - + /** * Get order admin date * From f7a746faf505c286fa65a579271838ca23cf287c Mon Sep 17 00:00:00 2001 From: PromInc Date: Tue, 21 Dec 2021 21:05:45 -0600 Subject: [PATCH 30/41] Use configuration for mage-messages cookie The mage-messages doesn't use the configuration values for the `mage-messages` cookie. --- .../Theme/Controller/Result/MessagePlugin.php | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Theme/Controller/Result/MessagePlugin.php b/app/code/Magento/Theme/Controller/Result/MessagePlugin.php index 056f1b21a9be8..b845184fe0574 100644 --- a/app/code/Magento/Theme/Controller/Result/MessagePlugin.php +++ b/app/code/Magento/Theme/Controller/Result/MessagePlugin.php @@ -11,6 +11,7 @@ use Magento\Framework\Translate\Inline\ParserInterface; use Magento\Framework\Translate\InlineInterface; use Magento\Framework\Session\Config\ConfigInterface; +use Magento\Framework\App\Config\ScopeConfigInterface; /** * Plugin for putting messages to cookies @@ -59,6 +60,11 @@ class MessagePlugin */ protected $sessionConfig; + /** + * @var ScopeConfigInterface + */ + protected $scopeConfig; + /** * @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory @@ -67,6 +73,7 @@ class MessagePlugin * @param \Magento\Framework\Serialize\Serializer\Json $serializer * @param InlineInterface $inlineTranslate * @param ConfigInterface $sessionConfig + * @param ScopeConfigInterface $scopeConfig */ public function __construct( \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager, @@ -75,7 +82,8 @@ public function __construct( \Magento\Framework\View\Element\Message\InterpretationStrategyInterface $interpretationStrategy, \Magento\Framework\Serialize\Serializer\Json $serializer, InlineInterface $inlineTranslate, - ConfigInterface $sessionConfig + ConfigInterface $sessionConfig, + ScopeConfigInterface $scopeConfig ) { $this->cookieManager = $cookieManager; $this->cookieMetadataFactory = $cookieMetadataFactory; @@ -84,6 +92,7 @@ public function __construct( $this->interpretationStrategy = $interpretationStrategy; $this->inlineTranslate = $inlineTranslate; $this->sessionConfig = $sessionConfig; + $this->scopeConfig = $scopeConfig; } /** @@ -171,11 +180,36 @@ private function setCookie(array $messages) } $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata(); - $publicCookieMetadata->setDurationOneYear(); - $publicCookieMetadata->setPath($this->sessionConfig->getCookiePath()); + + if( $configLifetime = $this->scopeConfig->getValue( + 'web/cookie/cookie_lifetime', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) ) { + $publicCookieMetadata->setDuration($configLifetime); + } else { + $publicCookieMetadata->setDurationOneYear(); + } + + if( $configPath = $this->scopeConfig->getValue( + 'web/cookie/cookie_path', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) ) { + $publicCookieMetadata->setPath($configPath); + } else { + $publicCookieMetadata->setPath($this->sessionConfig->getCookiePath()); + } + $publicCookieMetadata->setHttpOnly(false); + $publicCookieMetadata->setSameSite('Strict'); + if( $configDomain = $this->scopeConfig->getValue( + 'web/cookie/cookie_domain', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) ) { + $publicCookieMetadata->setDomain($configDomain); + } + $this->cookieManager->setPublicCookie( self::MESSAGES_COOKIES_NAME, $this->serializer->serialize($messages), From 30dd1a47bd7a473ad0e8a87ba0dc668ec7a9c5ae Mon Sep 17 00:00:00 2001 From: PromInc Date: Wed, 22 Dec 2021 05:28:45 -0600 Subject: [PATCH 31/41] Create Config.php --- app/code/Magento/Theme/Helper/Config.php | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 app/code/Magento/Theme/Helper/Config.php diff --git a/app/code/Magento/Theme/Helper/Config.php b/app/code/Magento/Theme/Helper/Config.php new file mode 100644 index 0000000000000..ffdd253ec1979 --- /dev/null +++ b/app/code/Magento/Theme/Helper/Config.php @@ -0,0 +1,41 @@ +_storeManager = $storeManager; + } + + /** + * @param string $path + * @param null|int $store + * @return null|string + */ + public function getConfig($path, $store = null) + { + $store = $this->_storeManager->getStore($store); + $result = $this->scopeConfig->getValue( + $path, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $store + ); + return $result; + } + +} From 0a9223d81103cb80d4afd9f970e6be53d3b57a05 Mon Sep 17 00:00:00 2001 From: PromInc Date: Wed, 22 Dec 2021 05:33:03 -0600 Subject: [PATCH 32/41] Pass the configured the cookie domain to Javascript --- app/code/Magento/Theme/view/frontend/templates/messages.phtml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Theme/view/frontend/templates/messages.phtml b/app/code/Magento/Theme/view/frontend/templates/messages.phtml index f863da70e8987..3d2d52257048e 100644 --- a/app/code/Magento/Theme/view/frontend/templates/messages.phtml +++ b/app/code/Magento/Theme/view/frontend/templates/messages.phtml @@ -4,6 +4,7 @@ * See COPYING.txt for license details. */ ?> +helper('Magento\Theme\Helper\Data'); ?>