Skip to content

Commit 15dd684

Browse files
[EngCom] Public Pull Requests - 2.3-develop
- merged latest code from mainline branch
2 parents 30658a8 + ff3c9b3 commit 15dd684

File tree

12 files changed

+98
-47
lines changed

12 files changed

+98
-47
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>

lib/internal/Magento/Framework/Locale/Format.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Framework\Locale;
77

8+
/**
9+
* Price locale format.
10+
*/
811
class Format implements \Magento\Framework\Locale\FormatInterface
912
{
1013
/**
@@ -38,7 +41,8 @@ public function __construct(
3841
}
3942

4043
/**
41-
* Returns the first found number from a string
44+
* Returns the first found number from a string.
45+
*
4246
* Parsing depends on given locale (grouping and decimal)
4347
*
4448
* Examples for input:
@@ -100,7 +104,7 @@ public function getPriceFormat($localeCode = null, $currencyCode = null)
100104
}
101105

102106
$formatter = new \NumberFormatter(
103-
$localeCode . '@currency=' . $currency->getCode(),
107+
$currency->getCode() ? $localeCode . '@currency=' . $currency->getCode() : $localeCode,
104108
\NumberFormatter::CURRENCY
105109
);
106110
$format = $formatter->getPattern();

lib/internal/Magento/Framework/Locale/Resolver.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
namespace Magento\Framework\Locale;
77

88
use Magento\Framework\App\Config\ScopeConfigInterface;
9+
use Magento\Framework\App\DeploymentConfig;
10+
use Magento\Framework\App\ObjectManager;
911

12+
/**
13+
* Manages locale config information.
14+
*/
1015
class Resolver implements ResolverInterface
1116
{
1217
/**
@@ -52,34 +57,42 @@ class Resolver implements ResolverInterface
5257
*/
5358
private $defaultLocalePath;
5459

60+
/**
61+
* @var DeploymentConfig
62+
*/
63+
private $deploymentConfig;
64+
5565
/**
5666
* @param ScopeConfigInterface $scopeConfig
5767
* @param string $defaultLocalePath
5868
* @param string $scopeType
5969
* @param mixed $locale
70+
* @param DeploymentConfig|null $deploymentConfig
6071
*/
6172
public function __construct(
6273
ScopeConfigInterface $scopeConfig,
6374
$defaultLocalePath,
6475
$scopeType,
65-
$locale = null
76+
$locale = null,
77+
DeploymentConfig $deploymentConfig = null
6678
) {
6779
$this->scopeConfig = $scopeConfig;
6880
$this->defaultLocalePath = $defaultLocalePath;
6981
$this->scopeType = $scopeType;
82+
$this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->create(DeploymentConfig::class);
7083
$this->setLocale($locale);
7184
}
7285

7386
/**
74-
* {@inheritdoc}
87+
* @inheritdoc
7588
*/
7689
public function getDefaultLocalePath()
7790
{
7891
return $this->defaultLocalePath;
7992
}
8093

8194
/**
82-
* {@inheritdoc}
95+
* @inheritdoc
8396
*/
8497
public function setDefaultLocale($locale)
8598
{
@@ -88,12 +101,15 @@ public function setDefaultLocale($locale)
88101
}
89102

90103
/**
91-
* {@inheritdoc}
104+
* @inheritdoc
92105
*/
93106
public function getDefaultLocale()
94107
{
95108
if (!$this->defaultLocale) {
96-
$locale = $this->scopeConfig->getValue($this->getDefaultLocalePath(), $this->scopeType);
109+
$locale = false;
110+
if ($this->deploymentConfig->isAvailable() && $this->deploymentConfig->isDbAvailable()) {
111+
$locale = $this->scopeConfig->getValue($this->getDefaultLocalePath(), $this->scopeType);
112+
}
97113
if (!$locale) {
98114
$locale = self::DEFAULT_LOCALE;
99115
}
@@ -103,7 +119,7 @@ public function getDefaultLocale()
103119
}
104120

105121
/**
106-
* {@inheritdoc}
122+
* @inheritdoc
107123
*/
108124
public function setLocale($locale = null)
109125
{
@@ -116,7 +132,7 @@ public function setLocale($locale = null)
116132
}
117133

118134
/**
119-
* {@inheritdoc}
135+
* @inheritdoc
120136
*/
121137
public function getLocale()
122138
{
@@ -127,7 +143,7 @@ public function getLocale()
127143
}
128144

129145
/**
130-
* {@inheritdoc}
146+
* @inheritdoc
131147
*/
132148
public function emulate($scopeId)
133149
{
@@ -147,7 +163,7 @@ public function emulate($scopeId)
147163
}
148164

149165
/**
150-
* {@inheritdoc}
166+
* @inheritdoc
151167
*/
152168
public function revert()
153169
{

0 commit comments

Comments
 (0)