Skip to content

Commit 267a2b9

Browse files
committed
Merge branch '2.3-develop' of https://github.com/magento/magento2ce into pr_2019_03_20
2 parents 05e8120 + 677f1b6 commit 267a2b9

File tree

19 files changed

+226
-66
lines changed

19 files changed

+226
-66
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Psr\Log\LoggerInterface;
2121
use Magento\AsynchronousOperations\Model\ResourceModel\Operation\OperationRepository;
2222
use Magento\Authorization\Model\UserContextInterface;
23+
use Magento\Framework\Encryption\Encryptor;
2324

2425
/**
2526
* Class MassSchedule used for adding multiple entities as Operations to Bulk Management with the status tracking
@@ -63,6 +64,11 @@ class MassSchedule
6364
*/
6465
private $userContext;
6566

67+
/**
68+
* @var Encryptor
69+
*/
70+
private $encryptor;
71+
6672
/**
6773
* Initialize dependencies.
6874
*
@@ -73,6 +79,7 @@ class MassSchedule
7379
* @param LoggerInterface $logger
7480
* @param OperationRepository $operationRepository
7581
* @param UserContextInterface $userContext
82+
* @param Encryptor|null $encryptor
7683
*/
7784
public function __construct(
7885
IdentityGeneratorInterface $identityService,
@@ -81,7 +88,8 @@ public function __construct(
8188
BulkManagementInterface $bulkManagement,
8289
LoggerInterface $logger,
8390
OperationRepository $operationRepository,
84-
UserContextInterface $userContext = null
91+
UserContextInterface $userContext = null,
92+
Encryptor $encryptor = null
8593
) {
8694
$this->identityService = $identityService;
8795
$this->itemStatusInterfaceFactory = $itemStatusInterfaceFactory;
@@ -90,6 +98,7 @@ public function __construct(
9098
$this->logger = $logger;
9199
$this->operationRepository = $operationRepository;
92100
$this->userContext = $userContext ?: ObjectManager::getInstance()->get(UserContextInterface::class);
101+
$this->encryptor = $encryptor ?: ObjectManager::getInstance()->get(Encryptor::class);
93102
}
94103

95104
/**
@@ -130,9 +139,13 @@ public function publishMass($topicName, array $entitiesArray, $groupId = null, $
130139
$requestItem = $this->itemStatusInterfaceFactory->create();
131140

132141
try {
133-
$operations[] = $this->operationRepository->createByTopic($topicName, $entityParams, $groupId);
142+
$operation = $this->operationRepository->createByTopic($topicName, $entityParams, $groupId);
143+
$operations[] = $operation;
134144
$requestItem->setId($key);
135145
$requestItem->setStatus(ItemStatusInterface::STATUS_ACCEPTED);
146+
$requestItem->setDataHash(
147+
$this->encryptor->hash($operation->getSerializedData(), Encryptor::HASH_VERSION_SHA256)
148+
);
136149
$requestItems[] = $requestItem;
137150
} catch (\Exception $exception) {
138151
$this->logger->error($exception);

app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@
146146
<editor>
147147
<validation>
148148
<rule name="required-entry" xsi:type="boolean">true</rule>
149-
<rule name="validate-xml-identifier" xsi:type="boolean">true</rule>
150149
</validation>
151150
<editorType>text</editorType>
152151
</editor>

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/Customer/Block/Address/Grid.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
2-
declare(strict_types=1);
32
/**
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
6+
declare(strict_types=1);
7+
78
namespace Magento\Customer\Block\Address;
89

910
use Magento\Customer\Model\ResourceModel\Address\CollectionFactory as AddressCollectionFactory;
@@ -236,8 +237,12 @@ private function getAddressCollection(): \Magento\Customer\Model\ResourceModel\A
236237
}
237238
/** @var \Magento\Customer\Model\ResourceModel\Address\Collection $collection */
238239
$collection = $this->addressCollectionFactory->create();
239-
$collection->setOrder('entity_id', 'desc')
240-
->setCustomerFilter([$this->getCustomer()->getId()]);
240+
$collection->setOrder('entity_id', 'desc');
241+
$collection->addFieldToFilter(
242+
'entity_id',
243+
['nin' => [$this->getDefaultBilling(), $this->getDefaultShipping()]]
244+
);
245+
$collection->setCustomerFilter([$this->getCustomer()->getId()]);
241246
$this->addressCollection = $collection;
242247
}
243248
return $this->addressCollection;

app/code/Magento/Customer/Test/Unit/Block/Address/GridTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function setUp()
8181
public function testGetChildHtml()
8282
{
8383
$customerId = 1;
84-
84+
$outputString = 'OutputString';
8585
/** @var \Magento\Framework\View\Element\BlockInterface|\PHPUnit_Framework_MockObject_MockObject $block */
8686
$block = $this->getMockBuilder(\Magento\Framework\View\Element\BlockInterface::class)
8787
->setMethods(['setCollection'])
@@ -93,7 +93,7 @@ public function testGetChildHtml()
9393
/** @var \PHPUnit_Framework_MockObject_MockObject */
9494
$addressCollection = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Address\Collection::class)
9595
->disableOriginalConstructor()
96-
->setMethods(['setOrder', 'setCustomerFilter', 'load'])
96+
->setMethods(['setOrder', 'setCustomerFilter', 'load','addFieldToFilter'])
9797
->getMock();
9898

9999
$layout->expects($this->atLeastOnce())->method('getChildName')->with('NameInLayout', 'pager')
@@ -108,12 +108,13 @@ public function testGetChildHtml()
108108
->willReturnSelf();
109109
$addressCollection->expects($this->atLeastOnce())->method('setCustomerFilter')->with([$customerId])
110110
->willReturnSelf();
111+
$addressCollection->expects(static::any())->method('addFieldToFilter')->willReturnSelf();
111112
$this->addressCollectionFactory->expects($this->atLeastOnce())->method('create')
112113
->willReturn($addressCollection);
113114
$block->expects($this->atLeastOnce())->method('setCollection')->with($addressCollection)->willReturnSelf();
114115
$this->gridBlock->setNameInLayout('NameInLayout');
115116
$this->gridBlock->setLayout($layout);
116-
$this->assertEquals('OutputString', $this->gridBlock->getChildHtml('pager'));
117+
$this->assertEquals($outputString, $this->gridBlock->getChildHtml('pager'));
117118
}
118119

119120
/**
@@ -137,7 +138,7 @@ public function testGetAdditionalAddresses()
137138
/** @var \PHPUnit_Framework_MockObject_MockObject */
138139
$addressCollection = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Address\Collection::class)
139140
->disableOriginalConstructor()
140-
->setMethods(['setOrder', 'setCustomerFilter', 'load', 'getIterator'])
141+
->setMethods(['setOrder', 'setCustomerFilter', 'load', 'getIterator','addFieldToFilter'])
141142
->getMock();
142143
$addressDataModel = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\AddressInterface::class);
143144
$address = $this->getMockBuilder(\Magento\Customer\Model\Address::class)
@@ -157,6 +158,7 @@ public function testGetAdditionalAddresses()
157158
->willReturnSelf();
158159
$addressCollection->expects($this->atLeastOnce())->method('setCustomerFilter')->with([$customerId])
159160
->willReturnSelf();
161+
$addressCollection->expects(static::any())->method('addFieldToFilter')->willReturnSelf();
160162
$addressCollection->expects($this->atLeastOnce())->method('getIterator')
161163
->willReturn(new \ArrayIterator($collection));
162164
$this->addressCollectionFactory->expects($this->atLeastOnce())->method('create')

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-

0 commit comments

Comments
 (0)