Skip to content

Commit 431a535

Browse files
authored
Merge pull request #5645 from magento-tsg/2.4-develop-php74-pr38
[TSG][PHP7.4] MFTF Fixes for 2.4 (pr38) (2.4-develop-php74)
2 parents 86677f6 + a71f832 commit 431a535

File tree

7 files changed

+40
-27
lines changed

7 files changed

+40
-27
lines changed

app/code/Magento/Catalog/Model/Product/TierPriceManagement.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ public function __construct(
9090
*/
9191
public function add($sku, $customerGroupId, $price, $qty)
9292
{
93-
if (!\Zend_Validate::is($price, 'Float') || $price <= 0 || !\Zend_Validate::is($qty, 'Float') || $qty <= 0) {
93+
if (!is_float($price) && !is_int($price) && !\Zend_Validate::is((string)$price, 'Float')
94+
|| !is_float($qty) && !is_int($qty) && !\Zend_Validate::is((string)$qty, 'Float')
95+
|| $price <= 0
96+
|| $qty <= 0
97+
) {
9498
throw new InputException(__('The data was invalid. Verify the data and try again.'));
9599
}
96100
$product = $this->productRepository->get($sku, ['edit_mode' => true]);

app/code/Magento/Checkout/Model/Sidebar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected function normalize($itemQty)
130130
$filter = new \Zend_Filter_LocalizedToNormalized(
131131
['locale' => $this->resolver->getLocale()]
132132
);
133-
return $filter->filter($itemQty);
133+
return $filter->filter((string)$itemQty);
134134
}
135135
return $itemQty;
136136
}

app/code/Magento/Customer/Ui/Component/Listing/Column/Confirmation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(
4545
}
4646

4747
/**
48-
* {@inheritdoc}
48+
* @inheritdoc
4949
*/
5050
public function prepareDataSource(array $dataSource)
5151
{
@@ -66,7 +66,7 @@ public function prepareDataSource(array $dataSource)
6666
private function getFieldLabel(array $item)
6767
{
6868
$isConfirmationRequired = $this->accountConfirmation->isConfirmationRequired(
69-
$item['website_id'][0],
69+
$item['website_id'][0] ?? null,
7070
$item[$item['id_field_name']],
7171
$item['email']
7272
);

app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ public function getData()
103103
$result['items'][]['file_name'] = $this->getPathToExportFile($this->fileIO->getPathInfo($file));
104104
}
105105

106-
$pageSize = (int) $this->request->getParam('paging')['pageSize'];
107-
$pageCurrent = (int) $this->request->getParam('paging')['current'];
106+
$paging = $this->request->getParam('paging');
107+
$pageSize = (int) ($paging['pageSize'] ?? 0);
108+
$pageCurrent = (int) ($paging['current'] ?? 0);
108109
$pageOffset = ($pageCurrent - 1) * $pageSize;
109110
$result['totalRecords'] = count($result['items']);
110111
$result['items'] = array_slice($result['items'], $pageOffset, $pageSize);

app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313
<argument name="categoryName" value="$$createCategory.name$$"/>
1414
</actionGroup>
1515
<!-- Choose First attribute filter -->
16-
<waitForElementVisible selector="{{StorefrontCategorySidebarSection.filterOptionTitle('$$createConfigProductAttribute.default_frontend_label$$')}}" stepKey="waitForCartRuleButton"/>
17-
<click selector="{{StorefrontCategorySidebarSection.filterOptionTitle('$$createConfigProductAttribute.default_frontend_label$$')}}" stepKey="expandFirstAttribute"/>
18-
<waitForPageLoad stepKey="waitForFilterLoad"/>
19-
<click selector="{{LayeredNavigationSection.filterOptionContent('$$createConfigProductAttribute.default_frontend_label$$','option2')}}" stepKey="expandFirstAttributeOption"/>
20-
<waitForPageLoad stepKey="waitForAttributeOption"/>
21-
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createFirstConfigurableProduct.name$$)}}" stepKey="seeFirstProduct"/>
22-
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createSecondConfigurableProduct.name$$)}}" stepKey="seeSecondProduct"/>
23-
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createThirdConfigurableProduct.name$$)}}" stepKey="seeSimpleProduct"/>
24-
<actionGroup ref="StorefrontGoToCategoryPageActionGroup" stepKey="goToCategoryPageAgain">
16+
<waitForElementVisible selector="{{StorefrontCategorySidebarSection.filterOptionTitle('$$createConfigProductAttribute.default_frontend_label$$')}}" after="goToCategoryPage" stepKey="waitForCartRuleButton"/>
17+
<click selector="{{StorefrontCategorySidebarSection.filterOptionTitle('$$createConfigProductAttribute.default_frontend_label$$')}}" after="waitForCartRuleButton" stepKey="expandFirstAttribute"/>
18+
<waitForPageLoad after="expandFirstAttribute" stepKey="waitForFilterLoad"/>
19+
<click selector="{{LayeredNavigationSection.filterOptionContent('$$createConfigProductAttribute.default_frontend_label$$','option2')}}" after="waitForFilterLoad" stepKey="expandFirstAttributeOption"/>
20+
<waitForPageLoad after="expandFirstAttributeOption" stepKey="waitForAttributeOption"/>
21+
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createFirstConfigurableProduct.name$$)}}" after="waitForAttributeOption" stepKey="seeFirstProduct"/>
22+
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createSecondConfigurableProduct.name$$)}}" after="seeFirstProduct" stepKey="seeSecondProduct"/>
23+
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createThirdConfigurableProduct.name$$)}}" after="seeSecondProduct" stepKey="seeSimpleProduct"/>
24+
<actionGroup ref="StorefrontGoToCategoryPageActionGroup" after="seeSimpleProduct" stepKey="goToCategoryPageAgain">
2525
<argument name="categoryName" value="$$createCategory.name$$"/>
2626
</actionGroup>
2727
<!-- Choose Second attribute filter -->
28-
<click selector="{{StorefrontCategorySidebarSection.filterOptionTitle('$$createConfigProductAttribute2.default_frontend_label$$')}}" stepKey="expandSecondAttributeOption"/>
29-
<waitForPageLoad stepKey="waitForFilterPageLoad"/>
30-
<click selector="{{LayeredNavigationSection.filterOptionContent('$$createConfigProductAttribute2.default_frontend_label$$','option1')}}" stepKey="expandSecondAttribute"/>
31-
<waitForPageLoad stepKey="waitForProductListLoad"/>
32-
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createFirstConfigurableProduct.name$$)}}" stepKey="seeFourthProduct"/>
33-
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createSecondConfigurableProduct.name$$)}}" stepKey="seeFifthProduct"/>
28+
<click selector="{{StorefrontCategorySidebarSection.filterOptionTitle('$$createConfigProductAttribute2.default_frontend_label$$')}}" after="goToCategoryPageAgain" stepKey="expandSecondAttributeOption"/>
29+
<waitForPageLoad after="expandSecondAttributeOption" stepKey="waitForFilterPageLoad"/>
30+
<click selector="{{LayeredNavigationSection.filterOptionContent('$$createConfigProductAttribute2.default_frontend_label$$','option1')}}" after="waitForFilterPageLoad" stepKey="expandSecondAttribute"/>
31+
<waitForPageLoad after="expandSecondAttribute" stepKey="waitForProductListLoad"/>
32+
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createFirstConfigurableProduct.name$$)}}" after="waitForProductListLoad" stepKey="seeFourthProduct"/>
33+
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createSecondConfigurableProduct.name$$)}}" after="seeFourthProduct" stepKey="seeFifthProduct"/>
3434
</test>
3535
</tests>

app/code/Magento/Swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,16 @@ protected function reformatSwatchLabels($swatchStoreValue = null)
9494
}
9595
$newSwatch = [];
9696
foreach ($swatchStoreValue as $key => $value) {
97-
if ($value[0] == '#') {
98-
$newSwatch[$key] = 'background: '.$value;
99-
} elseif ($value[0] == '/') {
100-
$mediaUrl = $this->swatchHelper->getSwatchMediaUrl();
101-
$newSwatch[$key] = 'background: url('.$mediaUrl.$value.'); background-size: cover;';
97+
if (!empty($value) && is_string($value)) {
98+
if ($value[0] === '#') {
99+
$newSwatch[$key] = 'background: ' . $value;
100+
} elseif ($value[0] === '/') {
101+
$mediaUrl = $this->swatchHelper->getSwatchMediaUrl();
102+
$newSwatch[$key] = 'background: url(' . $mediaUrl . $value . '); background-size: cover;';
103+
}
102104
}
103105
}
106+
104107
return $newSwatch;
105108
}
106109
}

app/code/Magento/User/Observer/Backend/AuthObserver.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
/**
2222
* User backend observer model for authentication
2323
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
24+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2425
*/
2526
class AuthObserver implements ObserverInterface
2627
{
@@ -173,7 +174,10 @@ private function _updateLockingInformation($user)
173174
$updateLockExpires = false;
174175
$lockThreshInterval = new \DateInterval('PT' . $lockThreshold.'S');
175176
// set first failure date when this is first failure or last first failure expired
176-
if (1 === $failuresNum || !$firstFailureDate || $now->diff($firstFailureDate) > $lockThreshInterval) {
177+
if (1 === $failuresNum
178+
|| !$firstFailureDate
179+
|| ($now->getTimestamp() - $firstFailureDate->getTimestamp()) > $lockThreshold
180+
) {
177181
$newFirstFailureDate = $now;
178182
// otherwise lock user
179183
} elseif ($failuresNum >= $maxFailures) {
@@ -184,6 +188,7 @@ private function _updateLockingInformation($user)
184188

185189
/**
186190
* Check whether the latest password is expired
191+
*
187192
* Side-effect can be when passwords were changed with different lifetime configuration settings
188193
*
189194
* @param array $latestPassword

0 commit comments

Comments
 (0)