Skip to content

Commit a78476f

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into mtf-eol
2 parents fd6d6c0 + ff3c9b3 commit a78476f

File tree

26 files changed

+1789
-55
lines changed

26 files changed

+1789
-55
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/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/Sales/Model/Order/Address/Validator.php

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class Validator
4949

5050
/**
5151
* @param DirectoryHelper $directoryHelper
52-
* @param CountryFactory $countryFactory
53-
* @param EavConfig $eavConfig
52+
* @param CountryFactory $countryFactory
53+
* @param EavConfig $eavConfig
5454
*/
5555
public function __construct(
5656
DirectoryHelper $directoryHelper,
@@ -61,6 +61,17 @@ public function __construct(
6161
$this->countryFactory = $countryFactory;
6262
$this->eavConfig = $eavConfig ?: ObjectManager::getInstance()
6363
->get(EavConfig::class);
64+
}
65+
66+
/**
67+
* Validate address.
68+
*
69+
* @param \Magento\Sales\Model\Order\Address $address
70+
* @return array
71+
*/
72+
public function validate(Address $address)
73+
{
74+
$warnings = [];
6475

6576
if ($this->isTelephoneRequired()) {
6677
$this->required['telephone'] = 'Phone Number';
@@ -73,16 +84,7 @@ public function __construct(
7384
if ($this->isFaxRequired()) {
7485
$this->required['fax'] = 'Fax';
7586
}
76-
}
7787

78-
/**
79-
*
80-
* @param \Magento\Sales\Model\Order\Address $address
81-
* @return array
82-
*/
83-
public function validate(Address $address)
84-
{
85-
$warnings = [];
8688
foreach ($this->required as $code => $label) {
8789
if (!$address->hasData($code)) {
8890
$warnings[] = sprintf('"%s" is required. Enter and try again.', $label);
@@ -195,23 +197,32 @@ protected function isStateRequired($countryId)
195197
}
196198

197199
/**
200+
* Check whether telephone is required for address.
201+
*
198202
* @return bool
203+
* @throws \Magento\Framework\Exception\LocalizedException
199204
*/
200205
protected function isTelephoneRequired()
201206
{
202207
return ($this->eavConfig->getAttribute('customer_address', 'telephone')->getIsRequired());
203208
}
204209

205210
/**
211+
* Check whether company is required for address.
212+
*
206213
* @return bool
214+
* @throws \Magento\Framework\Exception\LocalizedException
207215
*/
208216
protected function isCompanyRequired()
209217
{
210218
return ($this->eavConfig->getAttribute('customer_address', 'company')->getIsRequired());
211219
}
212220

213221
/**
222+
* Check whether telephone is required for address.
223+
*
214224
* @return bool
225+
* @throws \Magento\Framework\Exception\LocalizedException
215226
*/
216227
protected function isFaxRequired()
217228
{

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,4 +1015,9 @@
10151015
<preference
10161016
for="Magento\Sales\Api\OrderCustomerDelegateInterface"
10171017
type="Magento\Sales\Model\Order\OrderCustomerDelegate" />
1018+
<type name="Magento\Sales\Model\Order\Reorder\OrderedProductAvailabilityChecker">
1019+
<arguments>
1020+
<argument name="productAvailabilityChecks" xsi:type="array" />
1021+
</arguments>
1022+
</type>
10181023
</config>

app/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<preference for="Magento\Framework\Locale\ListsInterface" type="Magento\Framework\Locale\TranslatedLists" />
3939
<preference for="Magento\Framework\Locale\AvailableLocalesInterface" type="Magento\Framework\Locale\Deployed\Codes" />
4040
<preference for="Magento\Framework\Locale\OptionInterface" type="Magento\Framework\Locale\Deployed\Options" />
41-
<preference for="Magento\Framework\Lock\LockManagerInterface" type="Magento\Framework\Lock\Backend\Database" />
41+
<preference for="Magento\Framework\Lock\LockManagerInterface" type="Magento\Framework\Lock\Proxy" />
4242
<preference for="Magento\Framework\Api\AttributeTypeResolverInterface" type="Magento\Framework\Reflection\AttributeTypeResolver" />
4343
<preference for="Magento\Framework\Api\Search\SearchResultInterface" type="Magento\Framework\Api\Search\SearchResult" />
4444
<preference for="Magento\Framework\Api\Search\SearchCriteriaInterface" type="Magento\Framework\Api\Search\SearchCriteria"/>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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\Framework\Lock\Backend;
9+
10+
/**
11+
* \Magento\Framework\Lock\Backend\File test case
12+
*/
13+
class FileLockTest extends \PHPUnit\Framework\TestCase
14+
{
15+
/**
16+
* @var \Magento\Framework\Lock\Backend\FileLock
17+
*/
18+
private $model;
19+
20+
/**
21+
* @var \Magento\Framework\ObjectManagerInterface
22+
*/
23+
private $objectManager;
24+
25+
protected function setUp()
26+
{
27+
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
28+
$this->model = $this->objectManager->create(
29+
\Magento\Framework\Lock\Backend\FileLock::class,
30+
['path' => '/tmp']
31+
);
32+
}
33+
34+
public function testLockAndUnlock()
35+
{
36+
$name = 'test_lock';
37+
38+
$this->assertFalse($this->model->isLocked($name));
39+
40+
$this->assertTrue($this->model->lock($name));
41+
$this->assertTrue($this->model->isLocked($name));
42+
$this->assertFalse($this->model->lock($name, 2));
43+
44+
$this->assertTrue($this->model->unlock($name));
45+
$this->assertFalse($this->model->isLocked($name));
46+
}
47+
48+
public function testUnlockWithoutExistingLock()
49+
{
50+
$name = 'test_lock';
51+
52+
$this->assertFalse($this->model->isLocked($name));
53+
$this->assertFalse($this->model->unlock($name));
54+
}
55+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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\Framework\Lock\Backend;
9+
10+
use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperLock;
11+
use Magento\Framework\Lock\LockBackendFactory;
12+
use Magento\Framework\Config\File\ConfigFilePool;
13+
use Magento\Framework\App\DeploymentConfig\FileReader;
14+
use Magento\Framework\Stdlib\ArrayManager;
15+
16+
/**
17+
* \Magento\Framework\Lock\Backend\Zookeeper test case
18+
*/
19+
class ZookeeperTest extends \PHPUnit\Framework\TestCase
20+
{
21+
/**
22+
* @var FileReader
23+
*/
24+
private $configReader;
25+
26+
/**
27+
* @var \Magento\Framework\ObjectManagerInterface
28+
*/
29+
private $objectManager;
30+
31+
/**
32+
* @var LockBackendFactory
33+
*/
34+
private $lockBackendFactory;
35+
36+
/**
37+
* @var ArrayManager
38+
*/
39+
private $arrayManager;
40+
41+
/**
42+
* @var ZookeeperLock
43+
*/
44+
private $model;
45+
46+
/**
47+
* @inheritdoc
48+
*/
49+
protected function setUp()
50+
{
51+
if (!extension_loaded('zookeeper')) {
52+
$this->markTestSkipped('php extension Zookeeper is not installed.');
53+
}
54+
55+
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
56+
$this->configReader = $this->objectManager->get(FileReader::class);
57+
$this->lockBackendFactory = $this->objectManager->create(LockBackendFactory::class);
58+
$this->arrayManager = $this->objectManager->create(ArrayManager::class);
59+
$config = $this->configReader->load(ConfigFilePool::APP_ENV);
60+
61+
if ($this->arrayManager->get('lock/provider', $config) !== 'zookeeper') {
62+
$this->markTestSkipped('Zookeeper is not configured during installation.');
63+
}
64+
65+
$this->model = $this->lockBackendFactory->create();
66+
$this->assertInstanceOf(ZookeeperLock::class, $this->model);
67+
}
68+
69+
public function testLockAndUnlock()
70+
{
71+
$name = 'test_lock';
72+
73+
$this->assertFalse($this->model->isLocked($name));
74+
75+
$this->assertTrue($this->model->lock($name));
76+
$this->assertTrue($this->model->isLocked($name));
77+
$this->assertFalse($this->model->lock($name, 2));
78+
79+
$this->assertTrue($this->model->unlock($name));
80+
$this->assertFalse($this->model->isLocked($name));
81+
}
82+
83+
public function testUnlockWithoutExistingLock()
84+
{
85+
$name = 'test_lock';
86+
87+
$this->assertFalse($this->model->isLocked($name));
88+
$this->assertFalse($this->model->unlock($name));
89+
}
90+
}

0 commit comments

Comments
 (0)