Skip to content

Commit ae30d5e

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop latest changes
Accepted Community Pull Requests: - #30069: Stabilize CMS Page asset links tests (by @konarshankar07) - #30011: Directory and filename must be no more than 255 characters in length (by @lfluvisotto) - #30153: [Performance] Fix array merge in loop (by @ihor-sviziev) - #29827: [MFTF] add new AdminOpenConfigurationStoresPageActionGroup (by @Usik2203) - #28379: ISSUE-27397 - Fix phrase handling in widget validation (by @zaximus84) - #29015: Module catalog, Attribute Repository code validation regex (by @drc0) - #27869: \Magento\Framework\Filesystem\Io\File::read() should be able to accept resource in second argument (by @bnymn) - #27585: Remove redundant fieldset in sale rule form (by @edenduong) Fixed GitHub Issues: - #30164: Stabilize CMS Page asset links tests (reported by @sivaschenko) has been fixed in #30069 by @konarshankar07 in 2.4-develop branch Related commits: 1. a93e2e8 2. 3835116 3. 89b550a 4. 34e32f0 5. 0ba658f 6. 1eaa4e2 7. 5df1b7e 8. 64a2a38 9. 69b43d7 10. 2ce4e1e 11. 9630367 12. f80005a 13. 915c776 14. 999b239 - #29377: Filename is too long exception when importing media images (reported by @stephansteiner) has been fixed in #30011 by @lfluvisotto in 2.4-develop branch Related commits: 1. 52f39a4 - #30183: [Issue] [Performance] Fix array merge in loop (reported by @m2-assistant[bot]) has been fixed in #30153 by @ihor-sviziev in 2.4-develop branch Related commits: 1. 2381ab4 - #29848: [Issue] [MFTF] add new AdminOpenConfigurationStoresPageActionGroup (reported by @m2-assistant[bot]) has been fixed in #29827 by @Usik2203 in 2.4-develop branch Related commits: 1. 6c9a976 2. 3220bcd 3. cf66a7b 4. f6ba58c 5. c703749 - #27397: Creating custom widget instance validation is weird due to controller type mismatch (reported by @MellenIO) has been fixed in #28379 by @zaximus84 in 2.4-develop branch Related commits: 1. f20b05b 2. 1e4ef87 3. 3d82fe3 4. 0f1c459 5. d0e8bda - #29017: Product Attribute Repository do not respect attribute_code max length (reported by @drc0) has been fixed in #29015 by @drc0 in 2.4-develop branch Related commits: 1. d2c352d 2. 37dbcf7 3. 2663ff4 4. 78ed862 5. 65a67aa 6. 428e3d8 7. 431bfe5 - #27866: \Magento\Framework\Filesystem\Io\File::read() method is not compatible with \Magento\Framework\Filesystem\Io\IoInterface::read() (reported by @bnymn) has been fixed in #27869 by @bnymn in 2.4-develop branch Related commits: 1. cbc6637 2. d177789 3. 4024320 4. c160b44 5. ed111ae 6. a00f2d0 7. b480c4d 8. 2b2acee 9. b5bce0b - #29599: [Issue] Remove redundant fieldset in sale rule form (reported by @m2-assistant[bot]) has been fixed in #27585 by @edenduong in 2.4-develop branch Related commits: 1. 8da8356
2 parents 5e0d8a6 + 19efacf commit ae30d5e

File tree

60 files changed

+716
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+716
-318
lines changed

app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ public function __construct(
158158
protected function initTypeModels()
159159
{
160160
$productTypes = $this->_exportConfig->getEntityTypes(CatalogProduct::ENTITY);
161+
$disabledAttrs = [];
162+
$indexValueAttributes = [];
161163
foreach ($productTypes as $productTypeName => $productTypeConfig) {
162164
if (!($model = $this->_typeFactory->create($productTypeConfig['model']))) {
163165
throw new \Magento\Framework\Exception\LocalizedException(
@@ -174,21 +176,19 @@ protected function initTypeModels()
174176
}
175177
if ($model->isSuitable()) {
176178
$this->_productTypeModels[$productTypeName] = $model;
177-
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
178-
$this->_disabledAttrs = array_merge($this->_disabledAttrs, $model->getDisabledAttrs());
179-
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
180-
$this->_indexValueAttributes = array_merge(
181-
$this->_indexValueAttributes,
182-
$model->getIndexValueAttributes()
183-
);
179+
$disabledAttrs[] = $model->getDisabledAttrs();
180+
$indexValueAttributes[] = $model->getIndexValueAttributes();
184181
}
185182
}
186183
if (!$this->_productTypeModels) {
187184
throw new \Magento\Framework\Exception\LocalizedException(
188185
__('There are no product types available for export')
189186
);
190187
}
191-
$this->_disabledAttrs = array_unique($this->_disabledAttrs);
188+
$this->_disabledAttrs = array_unique(array_merge([], $this->_disabledAttrs, ...$disabledAttrs));
189+
$this->_indexValueAttributes = array_unique(
190+
array_merge([], $this->_indexValueAttributes, ...$indexValueAttributes)
191+
);
192192
return $this;
193193
}
194194

@@ -518,6 +518,8 @@ protected function getTierPrices(array $listSku, $table)
518518
if (isset($this->_parameters[\Magento\ImportExport\Model\Export::FILTER_ELEMENT_GROUP])) {
519519
$exportFilter = $this->_parameters[\Magento\ImportExport\Model\Export::FILTER_ELEMENT_GROUP];
520520
}
521+
$selectFields = [];
522+
$exportData = false;
521523
if ($table == ImportAdvancedPricing::TABLE_TIER_PRICE) {
522524
$selectFields = [
523525
ImportAdvancedPricing::COL_SKU => 'cpe.sku',

app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public function process(string $encodedMessage)
117117
$status = OperationInterface::STATUS_TYPE_COMPLETE;
118118
$errorCode = null;
119119
$messages = [];
120+
$entityParams = [];
120121
$topicName = $operation->getTopicName();
121122
$handlers = $this->configuration->getHandlers($topicName);
122123
try {
@@ -127,7 +128,7 @@ public function process(string $encodedMessage)
127128
$this->logger->error($e->getMessage());
128129
$status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED;
129130
$errorCode = $e->getCode();
130-
$messages[] = $e->getMessage();
131+
$messages[] = [$e->getMessage()];
131132
}
132133

133134
$outputData = null;
@@ -136,9 +137,7 @@ public function process(string $encodedMessage)
136137
$result = $this->executeHandler($callback, $entityParams);
137138
$status = $result['status'];
138139
$errorCode = $result['error_code'];
139-
// phpcs:disable Magento2.Performance.ForeachArrayMerge
140-
$messages = array_merge($messages, $result['messages']);
141-
// phpcs:enable Magento2.Performance.ForeachArrayMerge
140+
$messages[] = $result['messages'];
142141
$outputData = $result['output_data'];
143142
}
144143
}
@@ -157,7 +156,7 @@ public function process(string $encodedMessage)
157156
);
158157
$outputData = $this->jsonHelper->serialize($outputData);
159158
} catch (\Exception $e) {
160-
$messages[] = $e->getMessage();
159+
$messages[] = [$e->getMessage()];
161160
}
162161
}
163162

@@ -167,7 +166,7 @@ public function process(string $encodedMessage)
167166
$operation->getId(),
168167
$status,
169168
$errorCode,
170-
implode('; ', $messages),
169+
implode('; ', array_merge([], ...$messages)),
171170
$serializedData,
172171
$outputData
173172
);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminOpenConfigurationStoresPageActionGroup">
11+
<annotations>
12+
<description>Open configuration stores page.</description>
13+
</annotations>
14+
15+
<amOnPage url="{{AdminConfigurationStoresPage.url}}" stepKey="goToConfigurationStoresPage"/>
16+
<waitForPageLoad stepKey="waitPageLoad"/>
17+
</actionGroup>
18+
</actionGroups>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
10+
<page name="AdminConfigurationStoresPage" url="admin/system_config/edit/section/cms/" area="admin" module="Catalog">
11+
<section name="WYSIWYGOptionsSection"/>
12+
</page>
13+
</pages>

app/code/Magento/Backend/Test/Mftf/Page/AdminConfigurationStoresPage/ConfigurationStoresPage.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
-->
88
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
10+
<!-- @deprecated New Page was introduced. Please use "AdminConfigurationStoresPage" -->
1011
<page name="ConfigurationStoresPage" url="admin/system_config/edit/section/cms/" area="admin" module="Catalog">
1112
<section name="WYSIWYGOptionsSection"/>
1213
</page>

app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/CalculatorTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,10 @@ public function testGetterAmount($amountForBundle, $optionList, $expectedResult)
166166

167167
$optionSelections = [];
168168
foreach ($options as $option) {
169-
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
170-
$optionSelections = array_merge($optionSelections, $option->getSelections());
169+
$optionSelections[] = $option->getSelections();
171170
}
171+
$optionSelections = array_merge([], ...$optionSelections);
172+
172173
$this->selectionPriceListProvider->expects($this->any())->method('getPriceList')->willReturn($optionSelections);
173174

174175
$price = $this->createMock(BundleOptionPrice::class);

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -603,19 +603,15 @@ protected function populateInsertOptionValues(array $optionIds): array
603603
if ($assoc['position'] == $this->_cachedOptions[$entityId][$key]['index']
604604
&& $assoc['parent_id'] == $entityId) {
605605
$option['parent_id'] = $entityId;
606-
//phpcs:ignore Magento2.Performance.ForeachArrayMerge
607-
$optionValues = array_merge(
608-
$optionValues,
609-
$this->populateOptionValueTemplate($option, $optionId)
610-
);
606+
$optionValues[] = $this->populateOptionValueTemplate($option, $optionId);
611607
$this->_cachedOptions[$entityId][$key]['option_id'] = $optionId;
612608
break;
613609
}
614610
}
615611
}
616612
}
617613

618-
return $optionValues;
614+
return array_merge([], ...$optionValues);
619615
}
620616

621617
/**

app/code/Magento/Catalog/Model/Indexer/Product/Flat/TableBuilder.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ public function build($storeId, $changedIds, $valueFieldSuffix)
8686
//Create list of temporary tables based on available attributes attributes
8787
$valueTables = [];
8888
foreach ($temporaryEavAttributes as $tableName => $columns) {
89-
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
90-
$valueTables = array_merge(
91-
$valueTables,
92-
$this->_createTemporaryTable($this->_getTemporaryTableName($tableName), $columns, $valueFieldSuffix)
89+
$valueTables[] = $this->_createTemporaryTable(
90+
$this->_getTemporaryTableName($tableName),
91+
$columns,
92+
$valueFieldSuffix
9393
);
9494
}
95+
$valueTables = array_merge([], ...$valueTables);
9596

9697
//Fill "base" table which contains all available products
9798
$this->_fillTemporaryEntityTable($entityTableName, $entityTableColumns, $changedIds);

app/code/Magento/Catalog/Model/Product/Attribute/Repository.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Catalog\Model\Product\Attribute;
88

99
use Magento\Eav\Api\Data\AttributeInterface;
10+
use Magento\Eav\Model\Entity\Attribute;
1011
use Magento\Framework\Exception\InputException;
1112
use Magento\Framework\Exception\NoSuchEntityException;
1213

@@ -218,11 +219,16 @@ public function getCustomAttributesMetadata($dataObjectClassName = null)
218219
*/
219220
protected function generateCode($label)
220221
{
221-
$code = substr(preg_replace('/[^a-z_0-9]/', '_', $this->filterManager->translitUrl($label)), 0, 30);
222+
$code = substr(
223+
preg_replace('/[^a-z_0-9]/', '_', $this->filterManager->translitUrl($label)),
224+
0,
225+
Attribute::ATTRIBUTE_CODE_MAX_LENGTH
226+
);
222227
$validatorAttrCode = new \Zend_Validate_Regex(['pattern' => '/^[a-z][a-z_0-9]{0,29}[a-z0-9]$/']);
223228
if (!$validatorAttrCode->isValid($code)) {
224-
$code = 'attr_' . ($code ?: substr(md5(time()), 0, 8));
229+
$code = 'attr_' . ($code ?: substr(hash('sha256', time()), 0, 8));
225230
}
231+
226232
return $code;
227233
}
228234

@@ -235,7 +241,9 @@ protected function generateCode($label)
235241
*/
236242
protected function validateCode($code)
237243
{
238-
$validatorAttrCode = new \Zend_Validate_Regex(['pattern' => '/^[a-z][a-z_0-9]{0,30}$/']);
244+
$validatorAttrCode = new \Zend_Validate_Regex(
245+
['pattern' => '/^[a-z][a-z_0-9]{0,' . Attribute::ATTRIBUTE_CODE_MAX_LENGTH . '}$/']
246+
);
239247
if (!$validatorAttrCode->isValid($code)) {
240248
throw InputException::invalidFieldValue('attribute_code', $code);
241249
}

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CategoryLinkTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ public function testSaveCategoryLinks($newCategoryLinks, $dbCategoryLinks, $affe
145145
$expectedResult = [];
146146

147147
foreach ($affectedIds as $type => $ids) {
148-
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
149-
$expectedResult = array_merge($expectedResult, $ids);
148+
$expectedResult[] = $ids;
150149
// Verify if the correct insert, update and/or delete actions are performed:
151150
$this->setupExpectationsForConnection($type, $ids);
152151
}
152+
$expectedResult = array_merge([], ...$expectedResult);
153153

154154
$actualResult = $this->model->saveCategoryLinks($product, $newCategoryLinks);
155155

0 commit comments

Comments
 (0)