From d15f85a8d5ccccee5c2a51914d98db4eaa313f08 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra Date: Mon, 27 Apr 2020 16:18:26 +0300 Subject: [PATCH 01/12] MC-33699: Stabilize MFTF tests --- .../ImportExport/Ui/DataProvider/ExportFileDataProvider.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php b/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php index 57d1982d3500f..2b5af6ab5ca8d 100644 --- a/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php +++ b/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php @@ -103,8 +103,9 @@ public function getData() $result['items'][]['file_name'] = $this->getPathToExportFile($this->fileIO->getPathInfo($file)); } - $pageSize = (int) $this->request->getParam('paging')['pageSize']; - $pageCurrent = (int) $this->request->getParam('paging')['current']; + $paging = $this->request->getParam('paging'); + $pageSize = (int) ($paging['pageSize'] ?? 0); + $pageCurrent = (int) ($paging['current'] ?? 0); $pageOffset = ($pageCurrent - 1) * $pageSize; $result['totalRecords'] = count($result['items']); $result['items'] = array_slice($result['items'], $pageOffset, $pageSize); From f92ee249dbf95f756ff9b3a56d023c09ce232b82 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra Date: Mon, 27 Apr 2020 18:49:33 +0300 Subject: [PATCH 02/12] MC-33699: Stabilize MFTF tests --- .../Adminhtml/Attribute/Edit/Options/Visual.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php b/app/code/Magento/Swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php index 66ecd06c646e7..19685a291bd39 100644 --- a/app/code/Magento/Swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php +++ b/app/code/Magento/Swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php @@ -94,13 +94,16 @@ protected function reformatSwatchLabels($swatchStoreValue = null) } $newSwatch = []; foreach ($swatchStoreValue as $key => $value) { - if ($value[0] == '#') { - $newSwatch[$key] = 'background: '.$value; - } elseif ($value[0] == '/') { - $mediaUrl = $this->swatchHelper->getSwatchMediaUrl(); - $newSwatch[$key] = 'background: url('.$mediaUrl.$value.'); background-size: cover;'; + if (is_string($value) && !empty($value)) { + if ($value[0] == '#') { + $newSwatch[$key] = 'background: ' . $value; + } elseif ($value[0] == '/') { + $mediaUrl = $this->swatchHelper->getSwatchMediaUrl(); + $newSwatch[$key] = 'background: url(' . $mediaUrl . $value . '); background-size: cover;'; + } } } + return $newSwatch; } } From f6cff24fa4a54ab0f0221f9e8428dda457b9a435 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra Date: Tue, 28 Apr 2020 00:01:33 +0300 Subject: [PATCH 03/12] MC-33699: Stabilize MFTF tests --- .../Mftf/Test/AdminCreateImageSwatchTest.xml | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateImageSwatchTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateImageSwatchTest.xml index a42aadc497a7a..e67d0c763308c 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateImageSwatchTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateImageSwatchTest.xml @@ -89,20 +89,20 @@ - + adobe-thumb {$grabSwatch1} - + - + adobe-small {$grabSwatch2} - + - + adobe-base {$grabSwatch3} - + @@ -133,20 +133,20 @@ - + adobe-thumb {$grabSwatch4} - + - + adobe-small {$grabSwatch5} - + - + adobe-base {$grabSwatch6} - + @@ -154,19 +154,19 @@ - + adobe-thumb {$grabSwatch7} - + - + adobe-small {$grabSwatch8} - + - + adobe-base {$grabSwatch9} - + From c65846899c3ce346ce98c3288b85a3460f075f30 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra Date: Tue, 28 Apr 2020 12:28:29 +0300 Subject: [PATCH 04/12] MC-33699: Stabilize MFTF tests Fix AdminCheckResultsOfColorAndOtherFiltersTest --- ...CheckResultsOfColorAndOtherFiltersTest.xml | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml index 7b78b5193ef7c..cb2c8d9aa6a90 100644 --- a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml +++ b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml @@ -13,23 +13,23 @@ - - - - - - - - - + + + + + + + + + - - - - - - + + + + + + From 12296fa18d10352747192f25b70d38ae7b33208d Mon Sep 17 00:00:00 2001 From: DianaRusin Date: Tue, 28 Apr 2020 12:32:47 +0300 Subject: [PATCH 05/12] MC-33699: Stabilize MFTF tests --- app/code/Magento/Catalog/etc/events.xml | 1 + app/code/Magento/Checkout/Model/Sidebar.php | 2 +- .../AssertMiniShoppingCartSubTotalActionGroup.xml | 8 ++++---- .../Block/Adminhtml/Attribute/Edit/Options/Visual.php | 7 +++++-- app/code/Magento/User/Observer/Backend/AuthObserver.php | 4 ++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Catalog/etc/events.xml b/app/code/Magento/Catalog/etc/events.xml index 24186146c56f0..4274c8d058c19 100644 --- a/app/code/Magento/Catalog/etc/events.xml +++ b/app/code/Magento/Catalog/etc/events.xml @@ -42,6 +42,7 @@ + diff --git a/app/code/Magento/Checkout/Model/Sidebar.php b/app/code/Magento/Checkout/Model/Sidebar.php index 6f6655508f1b4..17cf40a73490c 100644 --- a/app/code/Magento/Checkout/Model/Sidebar.php +++ b/app/code/Magento/Checkout/Model/Sidebar.php @@ -130,7 +130,7 @@ protected function normalize($itemQty) $filter = new \Zend_Filter_LocalizedToNormalized( ['locale' => $this->resolver->getLocale()] ); - return $filter->filter($itemQty); + return $filter->filter((string)$itemQty); } return $itemQty; } diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertMiniShoppingCartSubTotalActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertMiniShoppingCartSubTotalActionGroup.xml index 3a7eb186c828d..ee88c42cf48bf 100644 --- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertMiniShoppingCartSubTotalActionGroup.xml +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertMiniShoppingCartSubTotalActionGroup.xml @@ -18,13 +18,13 @@ - + $grabMiniCartTotal {{dataQuote.subtotal}} - - + + $grabMiniCartTotal {{dataQuote.currency}} - + diff --git a/app/code/Magento/Swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php b/app/code/Magento/Swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php index 66ecd06c646e7..b463a9351bbe3 100644 --- a/app/code/Magento/Swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php +++ b/app/code/Magento/Swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php @@ -94,11 +94,14 @@ protected function reformatSwatchLabels($swatchStoreValue = null) } $newSwatch = []; foreach ($swatchStoreValue as $key => $value) { + if (!is_string($value)) { + continue; + } if ($value[0] == '#') { - $newSwatch[$key] = 'background: '.$value; + $newSwatch[$key] = 'background: ' . $value; } elseif ($value[0] == '/') { $mediaUrl = $this->swatchHelper->getSwatchMediaUrl(); - $newSwatch[$key] = 'background: url('.$mediaUrl.$value.'); background-size: cover;'; + $newSwatch[$key] = 'background: url(' . $mediaUrl . $value . '); background-size: cover;'; } } return $newSwatch; diff --git a/app/code/Magento/User/Observer/Backend/AuthObserver.php b/app/code/Magento/User/Observer/Backend/AuthObserver.php index 06b15a477d84d..20d073cb3f998 100644 --- a/app/code/Magento/User/Observer/Backend/AuthObserver.php +++ b/app/code/Magento/User/Observer/Backend/AuthObserver.php @@ -166,14 +166,14 @@ private function _updateLockingInformation($user) $failuresNum = (int)$user->getFailuresNum() + 1; /** @noinspection PhpAssignmentInConditionInspection */ if ($firstFailureDate = $user->getFirstFailure()) { - $firstFailureDate = new \DateTime($firstFailureDate); + $firstFailureDate = strtotime($user->getFirstFailure()); } $newFirstFailureDate = false; $updateLockExpires = false; $lockThreshInterval = new \DateInterval('PT' . $lockThreshold.'S'); // set first failure date when this is first failure or last first failure expired - if (1 === $failuresNum || !$firstFailureDate || $now->diff($firstFailureDate) > $lockThreshInterval) { + if (1 === $failuresNum || !$firstFailureDate || (\time() - $firstFailureDate) > $lockThreshold) { $newFirstFailureDate = $now; // otherwise lock user } elseif ($failuresNum >= $maxFailures) { From a2ae9b1dd111423f08c7337154193c74ae7db15b Mon Sep 17 00:00:00 2001 From: DianaRusin Date: Tue, 28 Apr 2020 16:29:53 +0300 Subject: [PATCH 06/12] MC-33699: Stabilize MFTF tests --- app/code/Magento/Catalog/etc/events.xml | 1 - .../User/Observer/Backend/AuthObserver.php | 2 ++ .../Framework/EntityManager/TypeResolver.php | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/etc/events.xml b/app/code/Magento/Catalog/etc/events.xml index 4274c8d058c19..24186146c56f0 100644 --- a/app/code/Magento/Catalog/etc/events.xml +++ b/app/code/Magento/Catalog/etc/events.xml @@ -42,7 +42,6 @@ - diff --git a/app/code/Magento/User/Observer/Backend/AuthObserver.php b/app/code/Magento/User/Observer/Backend/AuthObserver.php index 20d073cb3f998..a7bdbebb5eeec 100644 --- a/app/code/Magento/User/Observer/Backend/AuthObserver.php +++ b/app/code/Magento/User/Observer/Backend/AuthObserver.php @@ -21,6 +21,7 @@ /** * User backend observer model for authentication * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) */ class AuthObserver implements ObserverInterface { @@ -184,6 +185,7 @@ private function _updateLockingInformation($user) /** * Check whether the latest password is expired + * * Side-effect can be when passwords were changed with different lifetime configuration settings * * @param array $latestPassword diff --git a/lib/internal/Magento/Framework/EntityManager/TypeResolver.php b/lib/internal/Magento/Framework/EntityManager/TypeResolver.php index 1f559c01f11b6..c45ae6aaae41e 100644 --- a/lib/internal/Magento/Framework/EntityManager/TypeResolver.php +++ b/lib/internal/Magento/Framework/EntityManager/TypeResolver.php @@ -5,6 +5,8 @@ */ namespace Magento\Framework\EntityManager; +use Magento\Catalog\Model\Category; + /** * Resolves types. */ @@ -54,7 +56,7 @@ public function resolve($type) $interfaceNames = $reflectionClass->getInterfaceNames(); $dataInterfaces = []; foreach ($interfaceNames as $interfaceName) { - if (strpos($interfaceName, '\Api\Data\\') !== false) { + if ($this->isDataInterface($interfaceName, $type)) { $dataInterfaces[] = $interfaceName; } } @@ -73,4 +75,17 @@ public function resolve($type) } return $this->typeMapping[$className]; } + + /** + * Checks whether interface has Data type. + * + * @param string $interfaceName + * @param object $entityType + * @return bool + */ + private function isDataInterface(string $interfaceName, $entityType): bool + { + return strpos($interfaceName, '\Api\Data\\') !== false + && (!$entityType instanceof Category || preg_match('/Category(?!Tree)/', $interfaceName)); + } } From ba5aa765074236d1eadca7532766e64acb52f671 Mon Sep 17 00:00:00 2001 From: DianaRusin Date: Wed, 29 Apr 2020 09:39:32 +0300 Subject: [PATCH 07/12] MC-33699: Stabilize MFTF tests --- .../Customer/Ui/Component/Listing/Column/Confirmation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/Confirmation.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/Confirmation.php index 1786c52844a75..26cac677ccd10 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/Column/Confirmation.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/Confirmation.php @@ -45,7 +45,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function prepareDataSource(array $dataSource) { @@ -66,7 +66,7 @@ public function prepareDataSource(array $dataSource) private function getFieldLabel(array $item) { $isConfirmationRequired = $this->accountConfirmation->isConfirmationRequired( - $item['website_id'][0], + $item['website_id'][0] ?? null, $item[$item['id_field_name']], $item['email'] ); From 0446ec92e49fab7ecdb9da2061092c346f122daa Mon Sep 17 00:00:00 2001 From: DianaRusin Date: Wed, 29 Apr 2020 10:27:12 +0300 Subject: [PATCH 08/12] MC-33699: Stabilize MFTF tests --- .../Framework/EntityManager/TypeResolver.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/lib/internal/Magento/Framework/EntityManager/TypeResolver.php b/lib/internal/Magento/Framework/EntityManager/TypeResolver.php index c45ae6aaae41e..1f559c01f11b6 100644 --- a/lib/internal/Magento/Framework/EntityManager/TypeResolver.php +++ b/lib/internal/Magento/Framework/EntityManager/TypeResolver.php @@ -5,8 +5,6 @@ */ namespace Magento\Framework\EntityManager; -use Magento\Catalog\Model\Category; - /** * Resolves types. */ @@ -56,7 +54,7 @@ public function resolve($type) $interfaceNames = $reflectionClass->getInterfaceNames(); $dataInterfaces = []; foreach ($interfaceNames as $interfaceName) { - if ($this->isDataInterface($interfaceName, $type)) { + if (strpos($interfaceName, '\Api\Data\\') !== false) { $dataInterfaces[] = $interfaceName; } } @@ -75,17 +73,4 @@ public function resolve($type) } return $this->typeMapping[$className]; } - - /** - * Checks whether interface has Data type. - * - * @param string $interfaceName - * @param object $entityType - * @return bool - */ - private function isDataInterface(string $interfaceName, $entityType): bool - { - return strpos($interfaceName, '\Api\Data\\') !== false - && (!$entityType instanceof Category || preg_match('/Category(?!Tree)/', $interfaceName)); - } } From 3e29f3e6bb5646b6ea37e42e7fb7ee60ff663ac9 Mon Sep 17 00:00:00 2001 From: DianaRusin Date: Wed, 29 Apr 2020 17:48:20 +0300 Subject: [PATCH 09/12] MC-33699: Stabilize MFTF tests --- app/code/Magento/User/Observer/Backend/AuthObserver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/User/Observer/Backend/AuthObserver.php b/app/code/Magento/User/Observer/Backend/AuthObserver.php index a7bdbebb5eeec..bc099411eef9d 100644 --- a/app/code/Magento/User/Observer/Backend/AuthObserver.php +++ b/app/code/Magento/User/Observer/Backend/AuthObserver.php @@ -174,7 +174,7 @@ private function _updateLockingInformation($user) $updateLockExpires = false; $lockThreshInterval = new \DateInterval('PT' . $lockThreshold.'S'); // set first failure date when this is first failure or last first failure expired - if (1 === $failuresNum || !$firstFailureDate || (\time() - $firstFailureDate) > $lockThreshold) { + if (1 === $failuresNum || !$firstFailureDate || ($now->getTimestamp() - $firstFailureDate) > $lockThreshold) { $newFirstFailureDate = $now; // otherwise lock user } elseif ($failuresNum >= $maxFailures) { From c86ba9accb8de607c725d2d755c95c22888862e5 Mon Sep 17 00:00:00 2001 From: DianaRusin Date: Mon, 4 May 2020 11:06:36 +0300 Subject: [PATCH 10/12] MC-33699: Stabilize MFTF tests --- app/code/Magento/User/Observer/Backend/AuthObserver.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/User/Observer/Backend/AuthObserver.php b/app/code/Magento/User/Observer/Backend/AuthObserver.php index bc099411eef9d..9c90284807655 100644 --- a/app/code/Magento/User/Observer/Backend/AuthObserver.php +++ b/app/code/Magento/User/Observer/Backend/AuthObserver.php @@ -167,14 +167,17 @@ private function _updateLockingInformation($user) $failuresNum = (int)$user->getFailuresNum() + 1; /** @noinspection PhpAssignmentInConditionInspection */ if ($firstFailureDate = $user->getFirstFailure()) { - $firstFailureDate = strtotime($user->getFirstFailure()); + $firstFailureDate = new \DateTime($firstFailureDate); } $newFirstFailureDate = false; $updateLockExpires = false; $lockThreshInterval = new \DateInterval('PT' . $lockThreshold.'S'); // set first failure date when this is first failure or last first failure expired - if (1 === $failuresNum || !$firstFailureDate || ($now->getTimestamp() - $firstFailureDate) > $lockThreshold) { + if (1 === $failuresNum + || !$firstFailureDate + || ($now->getTimestamp() - $firstFailureDate->getTimestamp()) > $lockThreshold + ) { $newFirstFailureDate = $now; // otherwise lock user } elseif ($failuresNum >= $maxFailures) { From d84d514e203ee4e6b04d440ebfb720b4638c97be Mon Sep 17 00:00:00 2001 From: Myroslav Dobra Date: Mon, 4 May 2020 11:12:29 +0300 Subject: [PATCH 11/12] MC-33699: Stabilize MFTF tests --- .../Block/Adminhtml/Attribute/Edit/Options/Visual.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php b/app/code/Magento/Swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php index 19685a291bd39..8d2e939d77708 100644 --- a/app/code/Magento/Swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php +++ b/app/code/Magento/Swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php @@ -94,10 +94,10 @@ protected function reformatSwatchLabels($swatchStoreValue = null) } $newSwatch = []; foreach ($swatchStoreValue as $key => $value) { - if (is_string($value) && !empty($value)) { - if ($value[0] == '#') { + if (!empty($value) && is_string($value)) { + if ($value[0] === '#') { $newSwatch[$key] = 'background: ' . $value; - } elseif ($value[0] == '/') { + } elseif ($value[0] === '/') { $mediaUrl = $this->swatchHelper->getSwatchMediaUrl(); $newSwatch[$key] = 'background: url(' . $mediaUrl . $value . '); background-size: cover;'; } From c2ab2ff352d35b66e118af57cbc339cc4b29ab22 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra Date: Tue, 5 May 2020 00:41:33 +0300 Subject: [PATCH 12/12] MC-33699: Stabilize MFTF tests --- .../Magento/Catalog/Model/Product/TierPriceManagement.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/Product/TierPriceManagement.php b/app/code/Magento/Catalog/Model/Product/TierPriceManagement.php index f078349c2a8f4..16bdec2533fe6 100644 --- a/app/code/Magento/Catalog/Model/Product/TierPriceManagement.php +++ b/app/code/Magento/Catalog/Model/Product/TierPriceManagement.php @@ -90,7 +90,11 @@ public function __construct( */ public function add($sku, $customerGroupId, $price, $qty) { - if (!\Zend_Validate::is($price, 'Float') || $price <= 0 || !\Zend_Validate::is($qty, 'Float') || $qty <= 0) { + if (!is_float($price) && !is_int($price) && !\Zend_Validate::is((string)$price, 'Float') + || !is_float($qty) && !is_int($qty) && !\Zend_Validate::is((string)$qty, 'Float') + || $price <= 0 + || $qty <= 0 + ) { throw new InputException(__('The data was invalid. Verify the data and try again.')); } $product = $this->productRepository->get($sku, ['edit_mode' => true]);