Skip to content

Commit 637a6af

Browse files
[EngCom] Public Pull Requests - 2.3-develop
- merged latest code from mainline branch
2 parents 15dd684 + 0d881fc commit 637a6af

File tree

51 files changed

+1403
-270
lines changed

Some content is hidden

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

51 files changed

+1403
-270
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -282,25 +282,23 @@ public function getGridIdsJson()
282282
if (!$this->getUseSelectAll()) {
283283
return '';
284284
}
285-
/** @var \Magento\Framework\Data\Collection $allIdsCollection */
286-
$allIdsCollection = clone $this->getParentBlock()->getCollection();
287285

288-
if ($this->getMassactionIdField()) {
289-
$massActionIdField = $this->getMassactionIdField();
286+
/** @var \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection $collection */
287+
$collection = clone $this->getParentBlock()->getCollection();
288+
289+
if ($collection instanceof AbstractDb) {
290+
$idsSelect = clone $collection->getSelect();
291+
$idsSelect->reset(\Magento\Framework\DB\Select::ORDER);
292+
$idsSelect->reset(\Magento\Framework\DB\Select::LIMIT_COUNT);
293+
$idsSelect->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET);
294+
$idsSelect->reset(\Magento\Framework\DB\Select::COLUMNS);
295+
$idsSelect->columns($this->getMassactionIdField(), 'main_table');
296+
$idList = $collection->getConnection()->fetchCol($idsSelect);
290297
} else {
291-
$massActionIdField = $this->getParentBlock()->getMassactionIdField();
298+
$idList = $collection->setPageSize(0)->getColumnValues($this->getMassactionIdField());
292299
}
293300

294-
if ($allIdsCollection instanceof AbstractDb) {
295-
$allIdsCollection->getSelect()->limit();
296-
$allIdsCollection->clear();
297-
}
298-
299-
$gridIds = $allIdsCollection->setPageSize(0)->getColumnValues($massActionIdField);
300-
if (!empty($gridIds)) {
301-
return join(",", $gridIds);
302-
}
303-
return '';
301+
return implode(',', $idList);
304302
}
305303

306304
/**

app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -269,62 +269,6 @@ public function testGetGridIdsJsonWithoutUseSelectAll()
269269
$this->assertEmpty($this->_block->getGridIdsJson());
270270
}
271271

272-
/**
273-
* @param array $items
274-
* @param string $result
275-
*
276-
* @dataProvider dataProviderGetGridIdsJsonWithUseSelectAll
277-
*/
278-
public function testGetGridIdsJsonWithUseSelectAll(array $items, $result)
279-
{
280-
$this->_block->setUseSelectAll(true);
281-
282-
if ($this->_block->getMassactionIdField()) {
283-
$massActionIdField = $this->_block->getMassactionIdField();
284-
} else {
285-
$massActionIdField = $this->_block->getParentBlock()->getMassactionIdField();
286-
}
287-
288-
$collectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection::class)
289-
->disableOriginalConstructor()
290-
->getMock();
291-
292-
$this->_gridMock->expects($this->once())
293-
->method('getCollection')
294-
->willReturn($collectionMock);
295-
$collectionMock->expects($this->once())
296-
->method('setPageSize')
297-
->with(0)
298-
->willReturnSelf();
299-
$collectionMock->expects($this->once())
300-
->method('getColumnValues')
301-
->with($massActionIdField)
302-
->willReturn($items);
303-
304-
$this->assertEquals($result, $this->_block->getGridIdsJson());
305-
}
306-
307-
/**
308-
* @return array
309-
*/
310-
public function dataProviderGetGridIdsJsonWithUseSelectAll()
311-
{
312-
return [
313-
[
314-
[],
315-
'',
316-
],
317-
[
318-
[1],
319-
'1',
320-
],
321-
[
322-
[1, 2, 3],
323-
'1,2,3',
324-
],
325-
];
326-
}
327-
328272
/**
329273
* @param string $itemId
330274
* @param array|\Magento\Framework\DataObject $item

app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ public function getDirsCollection($path)
270270
$collection = $this->getCollection($path)
271271
->setCollectDirs(true)
272272
->setCollectFiles(false)
273-
->setCollectRecursively(false);
273+
->setCollectRecursively(false)
274+
->setOrder('basename', \Magento\Framework\Data\Collection\Filesystem::SORT_ORDER_ASC);
274275

275276
$conditions = $this->getConditionsForExcludeDirs();
276277

app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@ protected function generalTestGetDirsCollection($path, $collectionArray = [], $e
417417
->method('setCollectRecursively')
418418
->with(false)
419419
->willReturnSelf();
420+
$storageCollectionMock->expects($this->once())
421+
->method('setOrder')
422+
->with('basename', \Magento\Framework\Data\Collection\Filesystem::SORT_ORDER_ASC)
423+
->willReturnSelf();
420424
$storageCollectionMock->expects($this->once())
421425
->method('getIterator')
422426
->willReturn(new \ArrayIterator($collectionArray));

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,11 @@
248248
<type name="Magento\Tax\Model\Sales\Total\Quote\CommonTaxCollector">
249249
<plugin name="apply_tax_class_id" type="Magento\ConfigurableProduct\Plugin\Tax\Model\Sales\Total\Quote\CommonTaxCollector" />
250250
</type>
251+
<type name="Magento\Eav\Model\Entity\Attribute\Group">
252+
<arguments>
253+
<argument name="reservedSystemNames" xsi:type="array">
254+
<item name="configurable" xsi:type="string">configurable</item>
255+
</argument>
256+
</arguments>
257+
</type>
251258
</config>

app/code/Magento/DirectoryGraphQl/etc/schema.graphqls

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ type Query {
1010
type Currency {
1111
base_currency_code: String
1212
base_currency_symbol: String
13-
default_display_currecy_code: String
14-
default_display_currecy_symbol: String
13+
default_display_currecy_code: String @deprecated(reason: "Symbol was missed. Use `default_display_currency_code`.")
14+
default_display_currency_code: String
15+
default_display_currecy_symbol: String @deprecated(reason: "Symbol was missed. Use `default_display_currency_symbol`.")
16+
default_display_currency_symbol: String
1517
available_currency_codes: [String]
1618
exchange_rates: [ExchangeRate]
1719
}

app/code/Magento/Eav/Model/Entity/AbstractEntity.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,14 +1683,16 @@ public function saveAttribute(DataObject $object, $attributeCode)
16831683
$connection->beginTransaction();
16841684

16851685
try {
1686-
$select = $connection->select()->from($table, 'value_id')->where($where);
1687-
$origValueId = $connection->fetchOne($select);
1686+
$select = $connection->select()->from($table, ['value_id', 'value'])->where($where);
1687+
$origRow = $connection->fetchRow($select);
1688+
$origValueId = $origRow['value_id'] ?? false;
1689+
$origValue = $origRow['value'] ?? null;
16881690

16891691
if ($origValueId === false && $newValue !== null) {
16901692
$this->_insertAttribute($object, $attribute, $newValue);
16911693
} elseif ($origValueId !== false && $newValue !== null) {
16921694
$this->_updateAttribute($object, $attribute, $origValueId, $newValue);
1693-
} elseif ($origValueId !== false && $newValue === null) {
1695+
} elseif ($origValueId !== false && $newValue === null && $origValue !== null) {
16941696
$connection->delete($table, $where);
16951697
}
16961698
$this->_processAttributeValues();

app/code/Magento/Eav/Model/Entity/Attribute/Group.php

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

9+
use Magento\Eav\Api\Data\AttributeGroupExtensionInterface;
810
use Magento\Framework\Api\AttributeValueFactory;
11+
use Magento\Framework\Exception\LocalizedException;
912

1013
/**
14+
* Entity attribute group model
15+
*
1116
* @api
1217
* @method int getSortOrder()
1318
* @method \Magento\Eav\Model\Entity\Attribute\Group setSortOrder(int $value)
@@ -27,6 +32,11 @@ class Group extends \Magento\Framework\Model\AbstractExtensibleModel implements
2732
*/
2833
private $translitFilter;
2934

35+
/**
36+
* @var array
37+
*/
38+
private $reservedSystemNames = [];
39+
3040
/**
3141
* @param \Magento\Framework\Model\Context $context
3242
* @param \Magento\Framework\Registry $registry
@@ -35,7 +45,8 @@ class Group extends \Magento\Framework\Model\AbstractExtensibleModel implements
3545
* @param \Magento\Framework\Filter\Translit $translitFilter
3646
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
3747
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
38-
* @param array $data
48+
* @param array $data (optional)
49+
* @param array $reservedSystemNames (optional)
3950
*/
4051
public function __construct(
4152
\Magento\Framework\Model\Context $context,
@@ -45,7 +56,8 @@ public function __construct(
4556
\Magento\Framework\Filter\Translit $translitFilter,
4657
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
4758
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
48-
array $data = []
59+
array $data = [],
60+
array $reservedSystemNames = []
4961
) {
5062
parent::__construct(
5163
$context,
@@ -56,6 +68,7 @@ public function __construct(
5668
$resourceCollection,
5769
$data
5870
);
71+
$this->reservedSystemNames = $reservedSystemNames;
5972
$this->translitFilter = $translitFilter;
6073
}
6174

@@ -74,6 +87,7 @@ protected function _construct()
7487
* Checks if current attribute group exists
7588
*
7689
* @return bool
90+
* @throws LocalizedException
7791
* @codeCoverageIgnore
7892
*/
7993
public function itemExists()
@@ -85,6 +99,7 @@ public function itemExists()
8599
* Delete groups
86100
*
87101
* @return $this
102+
* @throws LocalizedException
88103
* @codeCoverageIgnore
89104
*/
90105
public function deleteGroups()
@@ -110,9 +125,10 @@ public function beforeSave()
110125
),
111126
'-'
112127
);
113-
if (empty($attributeGroupCode)) {
128+
$isReservedSystemName = in_array(strtolower($attributeGroupCode), $this->reservedSystemNames);
129+
if (empty($attributeGroupCode) || $isReservedSystemName) {
114130
// in the following code md5 is not used for security purposes
115-
$attributeGroupCode = md5($groupName);
131+
$attributeGroupCode = md5(strtolower($groupName));
116132
}
117133
$this->setAttributeGroupCode($attributeGroupCode);
118134
}
@@ -121,7 +137,8 @@ public function beforeSave()
121137
}
122138

123139
/**
124-
* {@inheritdoc}
140+
* @inheritdoc
141+
*
125142
* @codeCoverageIgnoreStart
126143
*/
127144
public function getAttributeGroupId()
@@ -130,64 +147,63 @@ public function getAttributeGroupId()
130147
}
131148

132149
/**
133-
* {@inheritdoc}
150+
* @inheritdoc
134151
*/
135152
public function getAttributeGroupName()
136153
{
137154
return $this->getData(self::GROUP_NAME);
138155
}
139156

140157
/**
141-
* {@inheritdoc}
158+
* @inheritdoc
142159
*/
143160
public function getAttributeSetId()
144161
{
145162
return $this->getData(self::ATTRIBUTE_SET_ID);
146163
}
147164

148165
/**
149-
* {@inheritdoc}
166+
* @inheritdoc
150167
*/
151168
public function setAttributeGroupId($attributeGroupId)
152169
{
153170
return $this->setData(self::GROUP_ID, $attributeGroupId);
154171
}
155172

156173
/**
157-
* {@inheritdoc}
174+
* @inheritdoc
158175
*/
159176
public function setAttributeGroupName($attributeGroupName)
160177
{
161178
return $this->setData(self::GROUP_NAME, $attributeGroupName);
162179
}
163180

164181
/**
165-
* {@inheritdoc}
182+
* @inheritdoc
166183
*/
167184
public function setAttributeSetId($attributeSetId)
168185
{
169186
return $this->setData(self::ATTRIBUTE_SET_ID, $attributeSetId);
170187
}
171188

172189
/**
173-
* {@inheritdoc}
190+
* @inheritdoc
174191
*
175-
* @return \Magento\Eav\Api\Data\AttributeGroupExtensionInterface|null
192+
* @return AttributeGroupExtensionInterface|null
176193
*/
177194
public function getExtensionAttributes()
178195
{
179196
return $this->_getExtensionAttributes();
180197
}
181198

182199
/**
183-
* {@inheritdoc}
200+
* @inheritdoc
184201
*
185-
* @param \Magento\Eav\Api\Data\AttributeGroupExtensionInterface $extensionAttributes
202+
* @param AttributeGroupExtensionInterface $extensionAttributes
186203
* @return $this
187204
*/
188-
public function setExtensionAttributes(
189-
\Magento\Eav\Api\Data\AttributeGroupExtensionInterface $extensionAttributes
190-
) {
205+
public function setExtensionAttributes(AttributeGroupExtensionInterface $extensionAttributes)
206+
{
191207
return $this->_setExtensionAttributes($extensionAttributes);
192208
}
193209

app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/GroupTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ protected function setUp()
4040
'resource' => $this->resourceMock,
4141
'translitFilter' => $translitFilter,
4242
'context' => $contextMock,
43+
'reservedSystemNames' => ['configurable'],
4344
];
4445
$objectManager = new ObjectManager($this);
4546
$this->model = $objectManager->getObject(
@@ -67,6 +68,8 @@ public function attributeGroupCodeDataProvider()
6768
{
6869
return [
6970
['General Group', 'general-group'],
71+
['configurable', md5('configurable')],
72+
['configurAble', md5('configurable')],
7073
['///', md5('///')],
7174
];
7275
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,3 @@
210210
</arguments>
211211
</type>
212212
</config>
213-

app/code/Magento/Elasticsearch/SearchAdapter/Aggregation/Builder/Term.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ public function build(
2222
array $queryResult,
2323
DataProviderInterface $dataProvider
2424
) {
25+
$buckets = $queryResult['aggregations'][$bucket->getName()]['buckets'] ?? [];
2526
$values = [];
26-
foreach ($queryResult['aggregations'][$bucket->getName()]['buckets'] as $resultBucket) {
27+
foreach ($buckets as $resultBucket) {
2728
$values[$resultBucket['key']] = [
2829
'value' => $resultBucket['key'],
2930
'count' => $resultBucket['doc_count'],
3031
];
3132
}
33+
3234
return $values;
3335
}
3436
}

0 commit comments

Comments
 (0)