Skip to content

Commit da206d7

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into MC-15671
2 parents 6890656 + 5358ec9 commit da206d7

File tree

29 files changed

+634
-75
lines changed

29 files changed

+634
-75
lines changed

app/code/Magento/Braintree/Controller/Paypal/PlaceOrder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function execute()
7474
$this->logger->critical($e);
7575
$this->messageManager->addExceptionMessage(
7676
$e,
77-
'The order #' . $quote->getReservedOrderId() . ' cannot be processed.'
77+
__('The order #%1 cannot be processed.', $quote->getReservedOrderId())
7878
);
7979
}
8080

app/code/Magento/Catalog/Api/Data/CategoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function setParentId($parentId);
4343
/**
4444
* Get category name
4545
*
46-
* @return string
46+
* @return string|null
4747
*/
4848
public function getName();
4949

app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,9 @@ protected function _getItemsData()
111111
$from = '';
112112
}
113113
if ($to == '*') {
114-
$to = '';
114+
$to = null;
115115
}
116-
$label = $this->renderRangeLabel(
117-
empty($from) ? 0 : $from,
118-
empty($to) ? 0 : $to
119-
);
116+
$label = $this->renderRangeLabel(empty($from) ? 0 : $from, $to);
120117
$value = $from . '-' . $to;
121118

122119
$data[] = [
@@ -141,7 +138,7 @@ protected function _getItemsData()
141138
protected function renderRangeLabel($fromPrice, $toPrice)
142139
{
143140
$formattedFromPrice = $this->priceCurrency->format($fromPrice);
144-
if ($toPrice === '') {
141+
if ($toPrice === null) {
145142
return __('%1 and above', $formattedFromPrice);
146143
} else {
147144
if ($fromPrice != $toPrice) {

app/code/Magento/Config/Model/Config/Backend/Admin/Usecustom.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ public function beforeSave()
5656
{
5757
$value = $this->getValue();
5858
if ($value == 1) {
59-
$customUrl = $this->getData('groups/url/fields/custom/value');
60-
if (empty($customUrl)) {
59+
$customUrlField = $this->getData('groups/url/fields/custom/value');
60+
$customUrlConfig = $this->_config->getValue('admin/url/custom');
61+
if (empty($customUrlField) && empty($customUrlConfig)) {
6162
throw new \Magento\Framework\Exception\LocalizedException(__('Please specify the admin custom URL.'));
6263
}
6364
}

app/code/Magento/Config/Model/Config/Backend/Serialized.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,18 @@ protected function _afterLoad()
5252
{
5353
$value = $this->getValue();
5454
if (!is_array($value)) {
55-
$this->setValue(empty($value) ? false : $this->serializer->unserialize($value));
55+
try {
56+
$this->setValue(empty($value) ? false : $this->serializer->unserialize($value));
57+
} catch (\Exception $e) {
58+
$this->_logger->critical(
59+
sprintf(
60+
'Failed to unserialize %s config value. The error is: %s',
61+
$this->getPath(),
62+
$e->getMessage()
63+
)
64+
);
65+
$this->setValue(false);
66+
}
5667
}
5768
}
5869

app/code/Magento/Config/Test/Unit/Model/Config/Backend/SerializedTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\Model\Context;
1010
use Magento\Framework\Serialize\Serializer\Json;
1111
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
12+
use Psr\Log\LoggerInterface;
1213

1314
class SerializedTest extends \PHPUnit\Framework\TestCase
1415
{
@@ -18,14 +19,20 @@ class SerializedTest extends \PHPUnit\Framework\TestCase
1819
/** @var Json|\PHPUnit_Framework_MockObject_MockObject */
1920
private $serializerMock;
2021

22+
/** @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject */
23+
private $loggerMock;
24+
2125
protected function setUp()
2226
{
2327
$objectManager = new ObjectManager($this);
2428
$this->serializerMock = $this->createMock(Json::class);
29+
$this->loggerMock = $this->createMock(LoggerInterface::class);
2530
$contextMock = $this->createMock(Context::class);
2631
$eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
2732
$contextMock->method('getEventDispatcher')
2833
->willReturn($eventManagerMock);
34+
$contextMock->method('getLogger')
35+
->willReturn($this->loggerMock);
2936
$this->serializedConfig = $objectManager->getObject(
3037
Serialized::class,
3138
[
@@ -72,6 +79,20 @@ public function afterLoadDataProvider()
7279
];
7380
}
7481

82+
public function testAfterLoadWithException()
83+
{
84+
$value = '{"key":';
85+
$expected = false;
86+
$this->serializedConfig->setValue($value);
87+
$this->serializerMock->expects($this->once())
88+
->method('unserialize')
89+
->willThrowException(new \Exception());
90+
$this->loggerMock->expects($this->once())
91+
->method('critical');
92+
$this->serializedConfig->afterLoad();
93+
$this->assertEquals($expected, $this->serializedConfig->getValue());
94+
}
95+
7596
/**
7697
* @param string $expected
7798
* @param int|double|string|array|boolean|null $value

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\Customer\Model\Data\Customer;
2020
use Magento\Customer\Model\Metadata\Validator;
2121
use Magento\Customer\Model\ResourceModel\Visitor\CollectionFactory;
22+
use Magento\Directory\Model\AllowedCountries;
2223
use Magento\Eav\Model\Validator\Attribute\Backend;
2324
use Magento\Framework\Api\ExtensibleDataObjectConverter;
2425
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -339,6 +340,11 @@ class AccountManagement implements AccountManagementInterface
339340
*/
340341
private $addressRegistry;
341342

343+
/**
344+
* @var AllowedCountries
345+
*/
346+
private $allowedCountriesReader;
347+
342348
/**
343349
* @param CustomerFactory $customerFactory
344350
* @param ManagerInterface $eventManager
@@ -371,8 +377,10 @@ class AccountManagement implements AccountManagementInterface
371377
* @param CollectionFactory|null $visitorCollectionFactory
372378
* @param SearchCriteriaBuilder|null $searchCriteriaBuilder
373379
* @param AddressRegistry|null $addressRegistry
380+
* @param AllowedCountries|null $allowedCountriesReader
374381
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
375382
* @SuppressWarnings(PHPMD.NPathComplexity)
383+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
376384
*/
377385
public function __construct(
378386
CustomerFactory $customerFactory,
@@ -405,7 +413,8 @@ public function __construct(
405413
SaveHandlerInterface $saveHandler = null,
406414
CollectionFactory $visitorCollectionFactory = null,
407415
SearchCriteriaBuilder $searchCriteriaBuilder = null,
408-
AddressRegistry $addressRegistry = null
416+
AddressRegistry $addressRegistry = null,
417+
AllowedCountries $allowedCountriesReader = null
409418
) {
410419
$this->customerFactory = $customerFactory;
411420
$this->eventManager = $eventManager;
@@ -445,6 +454,8 @@ public function __construct(
445454
?: ObjectManager::getInstance()->get(SearchCriteriaBuilder::class);
446455
$this->addressRegistry = $addressRegistry
447456
?: ObjectManager::getInstance()->get(AddressRegistry::class);
457+
$this->allowedCountriesReader = $allowedCountriesReader
458+
?: ObjectManager::getInstance()->get(AllowedCountries::class);
448459
}
449460

450461
/**
@@ -882,6 +893,9 @@ public function createAccountWithPasswordHash(
882893
}
883894
try {
884895
foreach ($customerAddresses as $address) {
896+
if (!$this->isAddressAllowedForWebsite($address, $customer->getStoreId())) {
897+
continue;
898+
}
885899
if ($address->getId()) {
886900
$newAddress = clone $address;
887901
$newAddress->setId(null);
@@ -1572,4 +1586,18 @@ private function setIgnoreValidationFlag(Customer $customer)
15721586
{
15731587
$customer->setData('ignore_validation_flag', true);
15741588
}
1589+
1590+
/**
1591+
* Check is address allowed for store
1592+
*
1593+
* @param AddressInterface $address
1594+
* @param int|null $storeId
1595+
* @return bool
1596+
*/
1597+
private function isAddressAllowedForWebsite(AddressInterface $address, $storeId): bool
1598+
{
1599+
$allowedCountries = $this->allowedCountriesReader->getAllowedCountries(ScopeInterface::SCOPE_STORE, $storeId);
1600+
1601+
return in_array($address->getCountryId(), $allowedCountries);
1602+
}
15751603
}

app/code/Magento/Dhl/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<field id="account" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
3232
<label>Account Number</label>
3333
</field>
34-
<field id="content_type" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
34+
<field id="content_type" translate="label comment" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
3535
<label>Content Type (Non Domestic)</label>
3636
<comment>Whether to use Documents or NonDocuments service for non domestic shipments. (Shipments within the EU are classed as domestic)</comment>
3737
<source_model>Magento\Dhl\Model\Source\Contenttype</source_model>

app/code/Magento/Dhl/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Title,Title
6161
Password,Password
6262
"Account Number","Account Number"
6363
"Content Type","Content Type"
64+
"Whether to use Documents or NonDocuments service for non domestic shipments. (Shipments within the EU are classed as domestic)","Whether to use Documents or NonDocuments service for non domestic shipments. (Shipments within the EU are classed as domestic)"
6465
"Calculate Handling Fee","Calculate Handling Fee"
6566
"Handling Applied","Handling Applied"
6667
"""Per Order"" allows a single handling fee for the entire order. ""Per Package"" allows an individual handling fee for each package.","""Per Order"" allows a single handling fee for the entire order. ""Per Package"" allows an individual handling fee for each package."

app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ public function importFromArray($arr)
10351035
$this->_items[$entityId]->addData($row);
10361036
}
10371037
}
1038+
$this->_setIsLoaded();
10381039
return $this;
10391040
}
10401041

0 commit comments

Comments
 (0)