Skip to content

Commit 7a8fba6

Browse files
akaashakaash
authored andcommitted
Merge branch '2.4-develop' into ACQE-4774
2 parents 6d79015 + af9ab20 commit 7a8fba6

File tree

41 files changed

+15621
-14375
lines changed

Some content is hidden

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

41 files changed

+15621
-14375
lines changed

app/code/Magento/AwsS3/Driver/AwsS3.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public function deleteDirectory($path): bool
257257
/**
258258
* @inheritDoc
259259
*/
260-
public function filePutContents($path, $content, $mode = null): int
260+
public function filePutContents($path, $content, $mode = null): bool|int
261261
{
262262
$path = $this->normalizeRelativePath($path, true);
263263
$config = self::CONFIG;
@@ -272,10 +272,11 @@ public function filePutContents($path, $content, $mode = null): int
272272

273273
try {
274274
$this->adapter->write($path, $content, new Config($config));
275-
return $this->adapter->fileSize($path)->fileSize();
275+
return ($this->adapter->fileSize($path)->fileSize() !== null)??true;
276+
276277
} catch (FlysystemFilesystemException | UnableToRetrieveMetadata $e) {
277278
$this->logger->error($e->getMessage());
278-
return 0;
279+
return false;
279280
}
280281
}
281282

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminAwsS3SyncZeroByteFilesTest">
12+
<annotations>
13+
<features value="AwsS3"/>
14+
<stories value="zero byte files are synced"/>
15+
<title value="S3 - Verify zero byte files are synced"/>
16+
<description value="Verifies that zero byte files are synced to AWS S3 with error."/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="AC-8252"/>
19+
<useCaseId value="ACP2E-1608"/>
20+
<group value="remote_storage_aws_s3"/>
21+
<group value="skip_in_cloud_native_s3"/>
22+
<group value="remote_storage_disabled"/>
23+
</annotations>
24+
25+
<before>
26+
<!-- Enable AWS S3 Remote Storage & Sync -->
27+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage"/>
28+
<!-- Copy Images to Import Directory for Product Images -->
29+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProductBaseImage">
30+
<argument name="source">dev/tests/acceptance/tests/_data/empty.jpg</argument>
31+
<argument name="destination">pub/media/empty.jpg</argument>
32+
</helper>
33+
</before>
34+
35+
<after>
36+
<!-- Delete Images on Local File System -->
37+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="deleteFileIfExists" stepKey="deleteLocalImage">
38+
<argument name="filePath">pub/media/empty.jpg</argument>
39+
</helper>
40+
<!-- Delete Images on S3 System -->
41+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteFileIfExists" stepKey="deleteS3Image">
42+
<argument name="filePath">pub/media/empty.jpg</argument>
43+
</helper>
44+
<!-- Disable AWS S3 Remote Storage -->
45+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage"/>
46+
</after>
47+
<magentoCLI command="remote-storage:sync" timeout="120" stepKey="syncRemoteStorage"/>
48+
<assertEquals stepKey="assertConfigTest">
49+
<expectedResult type="string">Uploading media files to remote storage.\n- empty.jpg\nEnd of upload.</expectedResult>
50+
<actualResult type="variable">$syncRemoteStorage</actualResult>
51+
</assertEquals>
52+
53+
</test>
54+
</tests>

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*
1616
* @api
1717
* @deprecated 100.2.0 in favour of UI component implementation
18+
* @see don't recommend this approach in favour of UI component implementation
1819
* @since 100.0.2
1920
*/
2021
class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Text
@@ -132,14 +133,16 @@ protected function _toLinkHtml($action, \Magento\Framework\DataObject $row)
132133
}
133134

134135
if (empty($action['id'])) {
135-
$action['id'] = 'id' .$this->random->getRandomString(10);
136+
$action['id'] = 'id' . $this->random->getRandomString(10);
136137
}
137138
$actionAttributes->setData($action);
138139
$onclick = $actionAttributes->getData('onclick');
139140
$style = $actionAttributes->getData('style');
140141
$actionAttributes->unsetData(['onclick', 'style']);
141142
$html = '<a ' . $actionAttributes->serialize() . '>' . $actionCaption . '</a>';
142143
if ($onclick) {
144+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
145+
$onclick = html_entity_decode($onclick);
143146
$html .= $this->secureHtmlRenderer->renderEventListenerAsTag('onclick', $onclick, "#{$action['id']}");
144147
}
145148
if ($style) {

app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/AttributeOptionProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function getOptions(array $optionIds, ?int $storeId, array $attributeCode
6363
'attribute_id' => 'a.attribute_id',
6464
'attribute_code' => 'a.attribute_code',
6565
'attribute_label' => 'a.frontend_label',
66+
'attribute_type' => 'a.frontend_input',
6667
'position' => 'attribute_configuration.position'
6768
]
6869
)
@@ -137,6 +138,7 @@ private function formatResult(Select $select): array
137138
'attribute_code' => $option['attribute_code'],
138139
'attribute_label' => $option['attribute_store_label']
139140
? $option['attribute_store_label'] : $option['attribute_label'],
141+
'attribute_type' => $option['attribute_type'],
140142
'position' => $option['position'],
141143
'options' => [],
142144
];

app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Attribute.php

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\Api\Search\AggregationValueInterface;
1414
use Magento\Framework\Api\Search\BucketInterface;
1515
use Magento\CatalogGraphQl\DataProvider\Product\LayeredNavigation\Formatter\LayerFormatter;
16+
use Magento\Config\Model\Config\Source\Yesno;
1617

1718
/**
1819
* @inheritdoc
@@ -49,18 +50,26 @@ class Attribute implements LayerBuilderInterface
4950
self::CATEGORY_BUCKET
5051
];
5152

53+
/**
54+
* @var Yesno
55+
*/
56+
private Yesno $YesNo;
57+
5258
/**
5359
* @param AttributeOptionProvider $attributeOptionProvider
5460
* @param LayerFormatter $layerFormatter
61+
* @param Yesno $YesNo
5562
* @param array $bucketNameFilter
5663
*/
5764
public function __construct(
5865
AttributeOptionProvider $attributeOptionProvider,
5966
LayerFormatter $layerFormatter,
67+
Yesno $YesNo,
6068
$bucketNameFilter = []
6169
) {
6270
$this->attributeOptionProvider = $attributeOptionProvider;
6371
$this->layerFormatter = $layerFormatter;
72+
$this->YesNo = $YesNo;
6473
$this->bucketNameFilter = \array_merge($this->bucketNameFilter, $bucketNameFilter);
6574
}
6675

@@ -87,7 +96,11 @@ public function build(AggregationInterface $aggregation, ?int $storeId): array
8796
isset($attribute['position']) ? $attribute['position'] : null
8897
);
8998

90-
$options = $this->getSortedOptions($bucket, isset($attribute['options']) ? $attribute['options'] : []);
99+
$options = $this->getSortedOptions(
100+
$bucket,
101+
isset($attribute['options']) ? $attribute['options'] : [],
102+
($attribute['attribute_type']) ? $attribute['attribute_type']: ''
103+
);
91104
foreach ($options as $option) {
92105
$result[$bucketName]['options'][] = $this->layerFormatter->buildItem(
93106
$option['label'],
@@ -168,9 +181,11 @@ function (AggregationValueInterface $value) {
168181
*
169182
* @param BucketInterface $bucket
170183
* @param array $optionLabels
184+
* @param string $attributeType
171185
* @return array
186+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
172187
*/
173-
private function getSortedOptions(BucketInterface $bucket, array $optionLabels): array
188+
private function getSortedOptions(BucketInterface $bucket, array $optionLabels, string $attributeType): array
174189
{
175190
/**
176191
* Option labels array has been sorted
@@ -179,7 +194,16 @@ private function getSortedOptions(BucketInterface $bucket, array $optionLabels):
179194
foreach ($bucket->getValues() as $value) {
180195
$metrics = $value->getMetrics();
181196
$optionValue = $metrics['value'];
182-
$optionLabel = $optionLabels[$optionValue] ?? $optionValue;
197+
if (isset($optionLabels[$optionValue])) {
198+
$optionLabel = $optionLabels[$optionValue];
199+
} else {
200+
if ($attributeType === 'boolean') {
201+
$yesNoOptions = $this->YesNo->toArray();
202+
$optionLabel = $yesNoOptions[$optionValue];
203+
} else {
204+
$optionLabel = $optionValue;
205+
}
206+
}
183207
$options[$optionValue] = $metrics + ['label' => $optionLabel];
184208
}
185209

@@ -188,7 +212,7 @@ private function getSortedOptions(BucketInterface $bucket, array $optionLabels):
188212
*/
189213
foreach ($options as $optionId => $option) {
190214
if (!is_array($options[$optionId])) {
191-
unset($options[$optionId]);
215+
unset($options[$optionId]);
192216
}
193217
}
194218

app/code/Magento/CatalogGraphQl/Model/AttributesJoiner.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function join(FieldNode $fieldNode, AbstractCollection $collection, Resol
6161
*
6262
* @param FieldNode $fieldNode
6363
* @param ResolveInfo $resolveInfo
64+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
6465
* @return string[]
6566
*/
6667
public function getQueryFields(FieldNode $fieldNode, ResolveInfo $resolveInfo): array
@@ -77,7 +78,11 @@ public function getQueryFields(FieldNode $fieldNode, ResolveInfo $resolveInfo):
7778
($spreadFragmentNode = $resolveInfo->fragments[$field->name->value])) {
7879

7980
foreach ($spreadFragmentNode->selectionSet->selections as $spreadNode) {
80-
if (isset($spreadNode->selectionSet->selections)) {
81+
if (isset($spreadNode->selectionSet->selections)
82+
&& $spreadNode->kind === NodeKind::INLINE_FRAGMENT) {
83+
$fragmentFields[] = $this->addInlineFragmentFields($resolveInfo, $spreadNode);
84+
} elseif (isset($spreadNode->selectionSet->selections)
85+
&& $spreadNode->kind !== NodeKind::INLINE_FRAGMENT) {
8186
$fragmentFields[] = $this->getQueryFields($spreadNode, $resolveInfo);
8287
} else {
8388
$selectedFields[] = $spreadNode->name->value;

app/code/Magento/CatalogGraphQl/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"magento/module-catalog-search": "*",
1515
"magento/framework": "*",
1616
"magento/module-graph-ql": "*",
17+
"magento/module-config": "*",
1718
"magento/module-advanced-search": "*"
1819
},
1920
"suggest": {

app/code/Magento/CatalogGraphQl/etc/module.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<module name="Magento_Store"/>
1414
<module name="Magento_Eav"/>
1515
<module name="Magento_GraphQl"/>
16+
<module name="Magento_Config"/>
1617
<module name="Magento_StoreGraphQl"/>
1718
<module name="Magento_EavGraphQl"/>
1819
</sequence>

app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection/StoreFrontCustomerAdvancedAttributesSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<element name="datedAttribute" type="input" selector="//input[@id='{{var}}']" parameterized="true"/>
1616
<element name="dropDownAttribute" type="select" selector="//select[@id='{{var}}']" parameterized="true"/>
1717
<element name="dropDownOptionAttribute" type="text" selector="//*[@id='{{var}}']/option[2]" parameterized="true"/>
18-
<element name="multiSelectFirstOptionAttribute" type="text" selector="//select[@id='{{var}}']/option[3]" parameterized="true"/>
18+
<element name="multiSelectFirstOptionAttribute" type="text" selector="//select[@id='{{var}}']/option[2]" parameterized="true"/>
1919
<element name="yesNoAttribute" type="select" selector="//select[@id='{{var}}']" parameterized="true"/>
2020
<element name="yesNoOptionAttribute" type="select" selector="//select[@id='{{var}}']/option[2]" parameterized="true"/>
2121
<element name="selectedOption" type="text" selector="//select[@id='{{var}}']/option[@selected='selected']" parameterized="true"/>

app/code/Magento/Developer/Model/Setup/Declaration/Schema/WhitelistGenerator.php

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ private function persistModule(Schema $schema, string $moduleName)
136136
. Diff::GENERATED_WHITELIST_FILE_NAME;
137137

138138
//We need to load whitelist file and update it with new revision of code.
139+
// phpcs:disable Magento2.Functions.DiscouragedFunction
139140
if (file_exists($whiteListFileName)) {
140141
$content = json_decode(file_get_contents($whiteListFileName), true);
141142
}
@@ -183,6 +184,7 @@ private function getElementsWithFixedName(array $tableData): array
183184
* @param string $tableName
184185
* @param array $tableData
185186
* @return array
187+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
186188
*/
187189
private function getElementsWithAutogeneratedName(Schema $schema, string $tableName, array $tableData) : array
188190
{
@@ -192,35 +194,42 @@ private function getElementsWithAutogeneratedName(Schema $schema, string $tableN
192194
$elementType = 'index';
193195
if (!empty($tableData[$elementType])) {
194196
foreach ($tableData[$elementType] as $tableElementData) {
195-
$indexName = $this->elementNameResolver->getFullIndexName(
196-
$table,
197-
$tableElementData['column'],
198-
$tableElementData['indexType'] ?? null
199-
);
200-
$declaredStructure[$elementType][$indexName] = true;
197+
if (isset($tableElementData['column'])) {
198+
$indexName = $this->elementNameResolver->getFullIndexName(
199+
$table,
200+
$tableElementData['column'],
201+
$tableElementData['indexType'] ?? null
202+
);
203+
$declaredStructure[$elementType][$indexName] = true;
204+
}
201205
}
202206
}
203207

204208
$elementType = 'constraint';
205209
if (!empty($tableData[$elementType])) {
206210
foreach ($tableData[$elementType] as $tableElementData) {
207-
if ($tableElementData['type'] === 'foreign') {
208-
$referenceTable = $schema->getTableByName($tableElementData['referenceTable']);
209-
$column = $table->getColumnByName($tableElementData['column']);
210-
$referenceColumn = $referenceTable->getColumnByName($tableElementData['referenceColumn']);
211-
$constraintName = ($column !== false && $referenceColumn !== false) ?
212-
$this->elementNameResolver->getFullFKName(
211+
$constraintName = null;
212+
if (isset($tableElementData['type'], $tableElementData['column'])) {
213+
if ($tableElementData['type'] === 'foreign') {
214+
$column = $table->getColumnByName($tableElementData['column']);
215+
$referenceTable = $schema->getTableByName($tableElementData['referenceTable'] ?? null);
216+
$referenceColumn = ($referenceTable !== false)
217+
? $referenceTable->getColumnByName($tableElementData['referenceColumn'] ?? null) : false;
218+
219+
$constraintName = ($column !== false && $referenceColumn !== false) ?
220+
$this->elementNameResolver->getFullFKName(
221+
$table,
222+
$column,
223+
$referenceTable,
224+
$referenceColumn
225+
) : null;
226+
} else {
227+
$constraintName = $this->elementNameResolver->getFullIndexName(
213228
$table,
214-
$column,
215-
$referenceTable,
216-
$referenceColumn
217-
) : null;
218-
} else {
219-
$constraintName = $this->elementNameResolver->getFullIndexName(
220-
$table,
221-
$tableElementData['column'],
222-
$tableElementData['type']
223-
);
229+
$tableElementData['column'],
230+
$tableElementData['type']
231+
);
232+
}
224233
}
225234
if ($constraintName) {
226235
$declaredStructure[$elementType][$constraintName] = true;

0 commit comments

Comments
 (0)