Skip to content

Commit fab0005

Browse files
committed
Merge remote-tracking branch 'origin/MC-41109' into 2.4.3-develop-pr132
2 parents b2f5eb1 + 052bb5d commit fab0005

File tree

13 files changed

+350
-22
lines changed

13 files changed

+350
-22
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ public function execute()
108108

109109
$result['url'] = $this->productMediaConfig->getTmpMediaUrl($result['file']);
110110
$result['file'] = $result['file'] . '.tmp';
111-
} catch (\Exception $e) {
111+
} catch (LocalizedException $e) {
112112
$result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
113+
} catch (\Throwable $e) {
114+
$result = ['error' => 'Something went wrong while saving the file(s).', 'errorcode' => 0];
113115
}
114116

115117
/** @var \Magento\Framework\Controller\Result\Raw $response */
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontRemoveFirstProductFromCompareActionGroup">
12+
<annotations>
13+
<description>Open Compare Products list and remove a product</description>
14+
</annotations>
15+
16+
<amOnPage url="{{StorefrontProductComparePage.url}}" stepKey="navigateToComparePage"/>
17+
<waitForElementVisible selector="{{StorefrontProductCompareMainSection.removeFirstItem}}" stepKey="waitForButton"/>
18+
<click selector="{{StorefrontProductCompareMainSection.removeFirstItem}}" stepKey="clickOnButton"/>
19+
<waitForElementVisible selector="{{ModalConfirmationSection.OkButton}}" stepKey="waitForModal"/>
20+
<scrollTo selector="{{ModalConfirmationSection.OkButton}}" stepKey="scrollToModal"/>
21+
<click selector="{{ModalConfirmationSection.OkButton}}" stepKey="ClickOkButton"/>
22+
<waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/>
23+
</actionGroup>
24+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductCompareMainSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<element name="ProductPriceByName" type="text" selector="//*[@id='product-comparison']//td[.//strong[@class='product-item-name']/a[contains(text(), '{{var1}}')]]//span[@class='price']" parameterized="true"/>
1515
<element name="ProductImageByName" type="text" selector="//*[@id='product-comparison']//td[.//strong[@class='product-item-name']/a[contains(text(), '{{var1}}')]]//img[@class='product-image-photo']" parameterized="true"/>
1616
<element name="ProductAttributeByCodeAndProductName" type="text" selector="//*[@id='product-comparison']//tr[.//th[./span[contains(text(), '{{var1}}')]]]//td[count(//*[@id='product-comparison']//tr//td[.//strong[@class='product-item-name']/a[contains(text(), '{{var2}}')]]/preceding-sibling::td)+1]/div" parameterized="true"/>
17+
<element name="removeFirstItem" type="button" selector="table.table-comparison a.delete"/>
1718
</section>
1819
</sections>

app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@
7878
<actionGroup ref="StorefrontGoToCategoryPageActionGroup" stepKey="openCategoryPage">
7979
<argument name="categoryName" value="$$category.name$$"/>
8080
</actionGroup>
81-
82-
<actionGroup ref="StorefrontOpenAndCheckComparisionActionGroup" stepKey="navigateToComparePage"/>
81+
<comment userInput="Comment is kept to preserve the step key for backward compatibility" stepKey="navigateToComparePage"/>
8382
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForStorefrontProductComparePageLoad"/>
8483

8584
<actionGroup ref="SeeProductInComparisonListActionGroup" stepKey="seeProductInCompareList">
@@ -92,11 +91,13 @@
9291
<argument name="categoryName" value="$$category.name$$"/>
9392
</actionGroup>
9493

95-
<actionGroup ref="StorefrontClearCompareActionGroup" stepKey="clickClearAll"/>
94+
<actionGroup ref="StorefrontRemoveFirstProductFromCompareActionGroup" stepKey="clickClearAll"/>
9695
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForConfirmPageLoad"/>
9796
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="confirmProdDelate"/>
9897
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForConfirmLoad"/>
99-
<comment userInput="Add product to compare list fom Category page | Comment is kept to preserve the step key for backward compatibility" stepKey="addToCmpFromCategPage"/>
98+
<actionGroup ref="StorefrontGoToCategoryPageActionGroup" stepKey="addToCmpFromCategPage">
99+
<argument name="categoryName" value="$$category.name$$"/>
100+
</actionGroup>
100101

101102
<actionGroup ref="StorefrontHoverProductOnCategoryPageActionGroup" stepKey="hoverOverProduct"/>
102103

@@ -108,11 +109,11 @@
108109
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="grabTextFromSuccessMessage2"/>
109110
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="assertSuccessMessage2"/>
110111

111-
<comment userInput="Check that product displays on add to compare widget | Comment is kept to preserve the step key for backward compatibility" stepKey="checkProdNameOnWidget"/>
112-
<seeElement selector="{{StorefrontComparisonSidebarSection.ProductTitleByName($$product.name$$)}}" stepKey="seeProdNameOnCmpWidget"/>
112+
<comment userInput="Comment is kept to preserve the step key for backward compatibility" stepKey="checkProdNameOnWidget"/>
113+
<comment userInput="Comment is kept to preserve the step key for backward compatibility" stepKey="seeProdNameOnCmpWidget"/>
113114

114115
<comment userInput="See product in the compare page" stepKey="seeProductInComparePage"/>
115-
<actionGroup ref="StorefrontOpenAndCheckComparisionActionGroup" stepKey="navigateToComparePage2"/>
116+
<comment userInput="Comment is kept to preserve the step key for backward compatibility" stepKey="navigateToComparePage2"/>
116117
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForStorefrontProductComparePageLoad2"/>
117118

118119
<actionGroup ref="SeeProductInComparisonListActionGroup" stepKey="seeProductInCompareList2">

app/code/Magento/ConfigurableProduct/Plugin/Model/Attribute/Backend/AttributeValidation.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\ConfigurableProduct\Plugin\Model\Attribute\Backend;
78

9+
use Closure;
810
use Magento\Catalog\Api\Data\ProductInterface;
911
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
12+
use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
13+
use Magento\Framework\DataObject;
1014

1115
/**
12-
* Skip validate attributes used for create configurable product
16+
* Skip validate attributes used for create configurable product.
1317
*/
1418
class AttributeValidation
1519
{
@@ -19,29 +23,36 @@ class AttributeValidation
1923
private $configurableProductType;
2024

2125
/**
22-
* AttributeValidation constructor.
26+
* @var array
27+
*/
28+
private $unskippableAttributes;
29+
30+
/**
2331
* @param Configurable $configurableProductType
32+
* @param array|null $unskippableAttributes
2433
*/
2534
public function __construct(
26-
Configurable $configurableProductType
35+
Configurable $configurableProductType,
36+
array $unskippableAttributes = []
2737
) {
2838
$this->configurableProductType = $configurableProductType;
39+
$this->unskippableAttributes = $unskippableAttributes;
2940
}
3041

3142
/**
32-
* @param \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend $subject
43+
* Around plugin to skip attribute validation used for create configurable product.
44+
*
45+
* @param AbstractBackend $subject
3346
* @param \Closure $proceed
34-
* @param \Magento\Framework\DataObject $entity
47+
* @param DataObject $entity
3548
* @return bool
3649
*/
37-
public function aroundValidate(
38-
\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend $subject,
39-
\Closure $proceed,
40-
\Magento\Framework\DataObject $entity
41-
) {
50+
public function aroundValidate(AbstractBackend $subject, Closure $proceed, DataObject $entity)
51+
{
4252
$attribute = $subject->getAttribute();
4353
if ($entity instanceof ProductInterface
4454
&& $entity->getTypeId() == Configurable::TYPE_CODE
55+
&& !in_array($attribute->getAttributeCode(), $this->unskippableAttributes)
4556
&& in_array(
4657
$attribute->getAttributeId(),
4758
$this->configurableProductType->getUsedProductAttributeIds($entity),
@@ -50,6 +61,7 @@ public function aroundValidate(
5061
) {
5162
return true;
5263
}
64+
5365
return $proceed($entity);
5466
}
5567
}

app/code/Magento/ConfigurableProduct/etc/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
<type name="Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend">
3434
<plugin name="ConfigurableProduct::skipValidation" type="Magento\ConfigurableProduct\Plugin\Model\Attribute\Backend\AttributeValidation"/>
3535
</type>
36+
<type name="Magento\ConfigurableProduct\Plugin\Model\Attribute\Backend\AttributeValidation">
37+
<arguments>
38+
<argument name="unskippableAttributes" xsi:type="array">
39+
<item name="custom_layout_update" xsi:type="string">custom_layout_update</item>
40+
</argument>
41+
</arguments>
42+
</type>
3643
<type name="Magento\Catalog\Model\Entity\Product\Attribute\Group\AttributeMapperInterface">
3744
<plugin name="configurable_product" type="Magento\ConfigurableProduct\Model\Entity\Product\Attribute\Group\AttributeMapper\Plugin" sortOrder="50" />
3845
</type>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Customer\Model\Validator;
9+
10+
use Magento\Customer\Model\Customer;
11+
use Magento\Framework\Validator\AbstractValidator;
12+
13+
/**
14+
* Customer name fields validator.
15+
*/
16+
class Name extends AbstractValidator
17+
{
18+
private const PATTERN_NAME = '/(?:[\p{L}\p{M}\,\-\_\.\'\s\d]){1,255}+/u';
19+
20+
/**
21+
* Validate name fields.
22+
*
23+
* @param Customer $customer
24+
* @return bool
25+
*/
26+
public function isValid($customer)
27+
{
28+
if (!$this->isValidName($customer->getFirstname())) {
29+
parent::_addMessages([['firstname' => 'First Name is not valid!']]);
30+
}
31+
32+
if (!$this->isValidName($customer->getLastname())) {
33+
parent::_addMessages([['lastname' => 'Last Name is not valid!']]);
34+
}
35+
36+
if (!$this->isValidName($customer->getMiddlename())) {
37+
parent::_addMessages([['middlename' => 'Middle Name is not valid!']]);
38+
}
39+
40+
return count($this->_messages) == 0;
41+
}
42+
43+
/**
44+
* Check if name field is valid.
45+
*
46+
* @param string|null $nameValue
47+
* @return bool
48+
*/
49+
private function isValidName($nameValue)
50+
{
51+
if ($nameValue != null) {
52+
if (preg_match(self::PATTERN_NAME, $nameValue, $matches)) {
53+
return $matches[0] == $nameValue;
54+
}
55+
}
56+
57+
return true;
58+
}
59+
}

app/code/Magento/Customer/Test/Mftf/Test/AdminExactMatchSearchInCustomerGridTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<before>
2222
<createData entity="Simple_US_Customer" stepKey="createFirstCustomer"/>
2323
<createData entity="Simple_US_Customer" stepKey="createSecondCustomer">
24-
<field key="firstname">&quot;Jane Doe&quot;</field>
24+
<field key="firstname">Jane Doe</field>
2525
</createData>
2626
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
2727
</before>

app/code/Magento/Customer/Test/Mftf/Test/StorefrontVerifyNoXssInjectionOnUpdateCustomerInformationAddAddressTest.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111
<test name="StorefrontVerifyNoXssInjectionOnUpdateCustomerInformationAddAddressTest">
1212
<annotations>
1313
<stories value="Update Customer Address"/>
14-
<title value="[Security] Verify No XSS Injection on Update Customer Information Add Address"/>
14+
<title value="DEPRECATED [Security] Verify No XSS Injection on Update Customer Information Add Address"/>
1515
<description value="Test log in to Storefront and Verify No XSS Injection on Update Customer Information Add Address"/>
1616
<testCaseId value="MC-10910"/>
1717
<severity value="CRITICAL"/>
1818
<group value="customer"/>
1919
<group value="mtf_migrated"/>
20+
<skip>
21+
<issueId value="DEPRECATED">Test outdated</issueId>
22+
</skip>
2023
</annotations>
2124

2225
<before>

app/code/Magento/Customer/etc/validation.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@
1818
<constraint alias="metadata_data_validator" class="Magento\Customer\Model\Metadata\Validator" />
1919
</entity_constraints>
2020
</rule>
21+
<rule name="check_name">
22+
<entity_constraints>
23+
<constraint alias="name_validator" class="Magento\Customer\Model\Validator\Name" />
24+
</entity_constraints>
25+
</rule>
2126
</rules>
2227
<groups>
2328
<group name="save">
2429
<uses>
2530
<use rule="check_eav"/>
31+
<use rule="check_name"/>
2632
</uses>
2733
</group>
2834
<group name="form">

0 commit comments

Comments
 (0)