Skip to content

Commit

Permalink
Merge pull request #5645 from magento-tsg/2.4-develop-php74-pr38
Browse files Browse the repository at this point in the history
[TSG][PHP7.4] MFTF Fixes for 2.4 (pr38) (2.4-develop-php74)
  • Loading branch information
fascinosum authored May 4, 2020
2 parents 86677f6 + a71f832 commit 431a535
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Checkout/Model/Sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function prepareDataSource(array $dataSource)
{
Expand All @@ -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']
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
<argument name="categoryName" value="$$createCategory.name$$"/>
</actionGroup>
<!-- Choose First attribute filter -->
<waitForElementVisible selector="{{StorefrontCategorySidebarSection.filterOptionTitle('$$createConfigProductAttribute.default_frontend_label$$')}}" stepKey="waitForCartRuleButton"/>
<click selector="{{StorefrontCategorySidebarSection.filterOptionTitle('$$createConfigProductAttribute.default_frontend_label$$')}}" stepKey="expandFirstAttribute"/>
<waitForPageLoad stepKey="waitForFilterLoad"/>
<click selector="{{LayeredNavigationSection.filterOptionContent('$$createConfigProductAttribute.default_frontend_label$$','option2')}}" stepKey="expandFirstAttributeOption"/>
<waitForPageLoad stepKey="waitForAttributeOption"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createFirstConfigurableProduct.name$$)}}" stepKey="seeFirstProduct"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createSecondConfigurableProduct.name$$)}}" stepKey="seeSecondProduct"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createThirdConfigurableProduct.name$$)}}" stepKey="seeSimpleProduct"/>
<actionGroup ref="StorefrontGoToCategoryPageActionGroup" stepKey="goToCategoryPageAgain">
<waitForElementVisible selector="{{StorefrontCategorySidebarSection.filterOptionTitle('$$createConfigProductAttribute.default_frontend_label$$')}}" after="goToCategoryPage" stepKey="waitForCartRuleButton"/>
<click selector="{{StorefrontCategorySidebarSection.filterOptionTitle('$$createConfigProductAttribute.default_frontend_label$$')}}" after="waitForCartRuleButton" stepKey="expandFirstAttribute"/>
<waitForPageLoad after="expandFirstAttribute" stepKey="waitForFilterLoad"/>
<click selector="{{LayeredNavigationSection.filterOptionContent('$$createConfigProductAttribute.default_frontend_label$$','option2')}}" after="waitForFilterLoad" stepKey="expandFirstAttributeOption"/>
<waitForPageLoad after="expandFirstAttributeOption" stepKey="waitForAttributeOption"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createFirstConfigurableProduct.name$$)}}" after="waitForAttributeOption" stepKey="seeFirstProduct"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createSecondConfigurableProduct.name$$)}}" after="seeFirstProduct" stepKey="seeSecondProduct"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createThirdConfigurableProduct.name$$)}}" after="seeSecondProduct" stepKey="seeSimpleProduct"/>
<actionGroup ref="StorefrontGoToCategoryPageActionGroup" after="seeSimpleProduct" stepKey="goToCategoryPageAgain">
<argument name="categoryName" value="$$createCategory.name$$"/>
</actionGroup>
<!-- Choose Second attribute filter -->
<click selector="{{StorefrontCategorySidebarSection.filterOptionTitle('$$createConfigProductAttribute2.default_frontend_label$$')}}" stepKey="expandSecondAttributeOption"/>
<waitForPageLoad stepKey="waitForFilterPageLoad"/>
<click selector="{{LayeredNavigationSection.filterOptionContent('$$createConfigProductAttribute2.default_frontend_label$$','option1')}}" stepKey="expandSecondAttribute"/>
<waitForPageLoad stepKey="waitForProductListLoad"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createFirstConfigurableProduct.name$$)}}" stepKey="seeFourthProduct"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createSecondConfigurableProduct.name$$)}}" stepKey="seeFifthProduct"/>
<click selector="{{StorefrontCategorySidebarSection.filterOptionTitle('$$createConfigProductAttribute2.default_frontend_label$$')}}" after="goToCategoryPageAgain" stepKey="expandSecondAttributeOption"/>
<waitForPageLoad after="expandSecondAttributeOption" stepKey="waitForFilterPageLoad"/>
<click selector="{{LayeredNavigationSection.filterOptionContent('$$createConfigProductAttribute2.default_frontend_label$$','option1')}}" after="waitForFilterPageLoad" stepKey="expandSecondAttribute"/>
<waitForPageLoad after="expandSecondAttribute" stepKey="waitForProductListLoad"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createFirstConfigurableProduct.name$$)}}" after="waitForProductListLoad" stepKey="seeFourthProduct"/>
<seeElement selector="{{StorefrontCategoryMainSection.specifiedProductItemInfo($$createSecondConfigurableProduct.name$$)}}" after="seeFourthProduct" stepKey="seeFifthProduct"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -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 (!empty($value) && is_string($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;
}
}
7 changes: 6 additions & 1 deletion app/code/Magento/User/Observer/Backend/AuthObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/**
* User backend observer model for authentication
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
*/
class AuthObserver implements ObserverInterface
{
Expand Down Expand Up @@ -173,7 +174,10 @@ 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 || $now->diff($firstFailureDate) > $lockThreshInterval) {
if (1 === $failuresNum
|| !$firstFailureDate
|| ($now->getTimestamp() - $firstFailureDate->getTimestamp()) > $lockThreshold
) {
$newFirstFailureDate = $now;
// otherwise lock user
} elseif ($failuresNum >= $maxFailures) {
Expand All @@ -184,6 +188,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
Expand Down

0 comments on commit 431a535

Please sign in to comment.