Skip to content

Commit 567e684

Browse files
committed
Merge branch '2.3-develop' of github.com:magento/magento2ce into MC-19929-23dev
2 parents 992dd1c + 5a8518c commit 567e684

File tree

30 files changed

+744
-218
lines changed

30 files changed

+744
-218
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product/Validator.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
use Magento\Catalog\Model\Product\Attribute\Backend\Sku;
1111

1212
/**
13-
* Class Validator
13+
* Product import model validator
1414
*
1515
* @api
1616
* @since 100.0.2
1717
*/
1818
class Validator extends AbstractValidator implements RowValidatorInterface
1919
{
20+
private const ERROR_SKU_MARGINAL_WHITESPACES = "Sku contains marginal whitespaces";
21+
2022
/**
2123
* @var RowValidatorInterface[]|AbstractValidator[]
2224
*/
@@ -72,8 +74,12 @@ protected function textValidation($attrCode, $type)
7274
$val = $this->string->cleanString($this->_rowData[$attrCode]);
7375
if ($type == 'text') {
7476
$valid = $this->string->strlen($val) < Product::DB_MAX_TEXT_LENGTH;
75-
} else if ($attrCode == Product::COL_SKU) {
77+
} elseif ($attrCode == Product::COL_SKU) {
7678
$valid = $this->string->strlen($val) <= SKU::SKU_MAX_LENGTH;
79+
if ($this->string->strlen($val) !== $this->string->strlen(trim($val))) {
80+
$this->_addMessages([self::ERROR_SKU_MARGINAL_WHITESPACES]);
81+
return false;
82+
}
7783
} else {
7884
$valid = $this->string->strlen($val) < Product::DB_MAX_VARCHAR_LENGTH;
7985
}
@@ -359,5 +365,7 @@ public function init($context)
359365
foreach ($this->validators as $validator) {
360366
$validator->init($context);
361367
}
368+
369+
return $this;
362370
}
363371
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,10 +1045,10 @@ private function changePasswordForCustomer($customer, $currentPassword, $newPass
10451045
}
10461046
$customerEmail = $customer->getEmail();
10471047
$this->credentialsValidator->checkPasswordDifferentFromEmail($customerEmail, $newPassword);
1048+
$this->checkPasswordStrength($newPassword);
10481049
$customerSecure = $this->customerRegistry->retrieveSecureData($customer->getId());
10491050
$customerSecure->setRpToken(null);
10501051
$customerSecure->setRpTokenCreatedAt(null);
1051-
$this->checkPasswordStrength($newPassword);
10521052
$customerSecure->setPasswordHash($this->createPasswordHash($newPassword));
10531053
$this->destroyCustomerSessions($customer->getId());
10541054
$this->disableAddressValidation($customer);
@@ -1630,6 +1630,7 @@ private function getEmailNotification()
16301630
*/
16311631
private function destroyCustomerSessions($customerId)
16321632
{
1633+
$this->sessionManager->regenerateId();
16331634
$sessionLifetime = $this->scopeConfig->getValue(
16341635
\Magento\Framework\Session\Config::XML_PATH_COOKIE_LIFETIME,
16351636
\Magento\Store\Model\ScopeInterface::SCOPE_STORE

app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,7 @@ public function testChangePassword()
15511551
->with($customer);
15521552

15531553
$this->sessionManager->expects($this->atLeastOnce())->method('getSessionId');
1554+
$this->sessionManager->expects($this->atLeastOnce())->method('regenerateId');
15541555

15551556
$visitor = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class)
15561557
->disableOriginalConstructor()
@@ -1628,6 +1629,7 @@ function ($string) {
16281629

16291630
$this->sessionManager->method('isSessionExists')->willReturn(false);
16301631
$this->sessionManager->expects($this->atLeastOnce())->method('getSessionId');
1632+
$this->sessionManager->expects($this->atLeastOnce())->method('regenerateId');
16311633
$visitor = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class)
16321634
->disableOriginalConstructor()
16331635
->setMethods(['getSessionId'])

app/code/Magento/Eav/Model/Config.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ class Config
157157

158158
/**
159159
* @param \Magento\Framework\App\CacheInterface $cache
160-
* @param \Magento\Eav\Model\Entity\TypeFactory $entityTypeFactory
161-
* @param \Magento\Eav\Model\ResourceModel\Entity\Type\CollectionFactory $entityTypeCollectionFactory
160+
* @param Entity\TypeFactory $entityTypeFactory
161+
* @param ResourceModel\Entity\Type\CollectionFactory $entityTypeCollectionFactory
162162
* @param \Magento\Framework\App\Cache\StateInterface $cacheState
163163
* @param \Magento\Framework\Validator\UniversalFactory $universalFactory
164-
* @param SerializerInterface $serializer
165-
* @param ScopeConfigInterface $scopeConfig
164+
* @param SerializerInterface|null $serializer
165+
* @param ScopeConfigInterface|null $scopeConfig
166166
* @param array $attributesForPreload
167167
* @codeCoverageIgnore
168168
*/
@@ -374,7 +374,9 @@ protected function _initEntityTypes()
374374
}
375375
\Magento\Framework\Profiler::start('EAV: ' . __METHOD__, ['group' => 'EAV', 'method' => __METHOD__]);
376376

377-
if ($this->isCacheEnabled() && ($cache = $this->_cache->load(self::ENTITIES_CACHE_ID))) {
377+
if ($this->isCacheEnabled() &&
378+
($cache = $this->_cache->load(self::ENTITIES_CACHE_ID))
379+
) {
378380
$this->_entityTypeData = $this->serializer->unserialize($cache);
379381
foreach ($this->_entityTypeData as $typeCode => $data) {
380382
$typeId = $data['entity_type_id'];

app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Set.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace Magento\Eav\Model\ResourceModel\Entity\Attribute;
88

9+
/**
10+
* Basic implementation for attribute sets
11+
*/
912
class Set extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
1013
{
1114
/**
@@ -24,8 +27,6 @@ class Set extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
2427
protected $eavConfig;
2528

2629
/**
27-
* Constructor
28-
*
2930
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
3031
* @param GroupFactory $attrGroupFactory
3132
* @param \Magento\Eav\Model\Config $eavConfig
@@ -54,7 +55,7 @@ protected function _construct()
5455
}
5556

5657
/**
57-
* Perform actions after object save
58+
* Perform actions after object save.
5859
*
5960
* @param \Magento\Framework\Model\AbstractModel $object
6061
* @return $this

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,14 @@
209209
</argument>
210210
</arguments>
211211
</type>
212+
<virtualType name="configured_eav_cache" type="Magento\Framework\App\Cache">
213+
<arguments>
214+
<argument name="cacheIdentifier" xsi:type="string">eav</argument>
215+
</arguments>
216+
</virtualType>
217+
<type name="Magento\Eav\Model\Config">
218+
<arguments>
219+
<argument name="cache" xsi:type="object">configured_eav_cache</argument>
220+
</arguments>
221+
</type>
212222
</config>

app/code/Magento/QuoteGraphQl/Model/Resolver/ShippingAddress/AvailableShippingMethods.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@
77

88
namespace Magento\QuoteGraphQl\Model\Resolver\ShippingAddress;
99

10-
use Magento\Directory\Model\Currency;
1110
use Magento\Framework\Api\ExtensibleDataObjectConverter;
1211
use Magento\Framework\Exception\LocalizedException;
13-
use Magento\Framework\Exception\NoSuchEntityException;
1412
use Magento\Framework\GraphQl\Config\Element\Field;
1513
use Magento\Framework\GraphQl\Query\ResolverInterface;
1614
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1715
use Magento\Quote\Api\Data\ShippingMethodInterface;
1816
use Magento\Quote\Model\Cart\ShippingMethodConverter;
19-
use Magento\Store\Api\Data\StoreInterface;
17+
use Magento\Quote\Model\Quote\TotalsCollector;
2018

2119
/**
2220
* @inheritdoc
@@ -33,16 +31,24 @@ class AvailableShippingMethods implements ResolverInterface
3331
*/
3432
private $shippingMethodConverter;
3533

34+
/**
35+
* @var TotalsCollector
36+
*/
37+
private $totalsCollector;
38+
3639
/**
3740
* @param ExtensibleDataObjectConverter $dataObjectConverter
3841
* @param ShippingMethodConverter $shippingMethodConverter
42+
* @param TotalsCollector $totalsCollector
3943
*/
4044
public function __construct(
4145
ExtensibleDataObjectConverter $dataObjectConverter,
42-
ShippingMethodConverter $shippingMethodConverter
46+
ShippingMethodConverter $shippingMethodConverter,
47+
TotalsCollector $totalsCollector
4348
) {
4449
$this->dataObjectConverter = $dataObjectConverter;
4550
$this->shippingMethodConverter = $shippingMethodConverter;
51+
$this->totalsCollector = $totalsCollector;
4652
}
4753

4854
/**
@@ -61,9 +67,8 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
6167
}
6268

6369
$address->setCollectShippingRates(true);
64-
$address->collectShippingRates();
6570
$cart = $address->getQuote();
66-
71+
$this->totalsCollector->collectAddressTotals($cart, $address);
6772
$methods = [];
6873
$shippingRates = $address->getGroupedAllShippingRates();
6974
foreach ($shippingRates as $carrierRates) {
@@ -88,7 +93,6 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
8893
* @param array $data
8994
* @param string $quoteCurrencyCode
9095
* @return array
91-
* @throws NoSuchEntityException
9296
*/
9397
private function processMoneyTypeData(array $data, string $quoteCurrencyCode): array
9498
{

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,24 @@
285285
<argument name="identifierName" xsi:type="string">theme_id</argument>
286286
</arguments>
287287
</type>
288+
<virtualType name="configured_design_cache" type="Magento\Framework\App\Cache">
289+
<arguments>
290+
<argument name="cacheIdentifier" xsi:type="string">layout</argument>
291+
</arguments>
292+
</virtualType>
293+
<virtualType name="design_context" type="Magento\Framework\Model\Context">
294+
<arguments>
295+
<argument name="cacheManager" xsi:type="object">configured_design_cache</argument>
296+
</arguments>
297+
</virtualType>
298+
<type name="Magento\Theme\Model\Design">
299+
<arguments>
300+
<argument name="context" xsi:type="object">design_context</argument>
301+
</arguments>
302+
</type>
303+
<type name="Magento\Theme\Model\Theme\ThemeProvider">
304+
<arguments>
305+
<argument name="cache" xsi:type="object">configured_design_cache</argument>
306+
</arguments>
307+
</type>
288308
</config>

app/etc/di.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,4 +1800,14 @@
18001800
</type>
18011801
<preference for="Magento\Framework\GraphQl\Query\ErrorHandlerInterface" type="Magento\Framework\GraphQl\Query\ErrorHandler"/>
18021802
<preference for="Magento\Framework\Filter\VariableResolverInterface" type="Magento\Framework\Filter\VariableResolver\StrategyResolver"/>
1803+
<virtualType name="configured_block_cache" type="Magento\Framework\App\Cache">
1804+
<arguments>
1805+
<argument name="cacheIdentifier" xsi:type="string">block_html</argument>
1806+
</arguments>
1807+
</virtualType>
1808+
<type name="Magento\Framework\View\Element\Context">
1809+
<arguments>
1810+
<argument name="cache" xsi:type="object">configured_block_cache</argument>
1811+
</arguments>
1812+
</type>
18031813
</config>

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetAvailableShippingMethodsTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,51 @@ public function testGetAvailableShippingMethods()
8282
);
8383
}
8484

85+
/**
86+
* Test case: get available shipping methods from current customer quote with configurable product
87+
*
88+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
89+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
90+
* @magentoApiDataFixture Magento/CatalogRule/_files/configurable_product.php
91+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_configurable_product.php
92+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
93+
*/
94+
public function testGetAvailableShippingMethodsWithConfigurableProduct()
95+
{
96+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
97+
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId), [], '', $this->getHeaderMap());
98+
99+
self::assertArrayHasKey('cart', $response);
100+
self::assertArrayHasKey('shipping_addresses', $response['cart']);
101+
self::assertCount(1, $response['cart']['shipping_addresses']);
102+
self::assertArrayHasKey('available_shipping_methods', $response['cart']['shipping_addresses'][0]);
103+
self::assertCount(1, $response['cart']['shipping_addresses'][0]['available_shipping_methods']);
104+
105+
$expectedAddressData = [
106+
'amount' => [
107+
'value' => 5,
108+
'currency' => 'USD',
109+
],
110+
'carrier_code' => 'flatrate',
111+
'carrier_title' => 'Flat Rate',
112+
'error_message' => '',
113+
'method_code' => 'flatrate',
114+
'method_title' => 'Fixed',
115+
'price_incl_tax' => [
116+
'value' => 5,
117+
'currency' => 'USD',
118+
],
119+
'price_excl_tax' => [
120+
'value' => 5,
121+
'currency' => 'USD',
122+
],
123+
];
124+
self::assertEquals(
125+
$expectedAddressData,
126+
$response['cart']['shipping_addresses'][0]['available_shipping_methods'][0]
127+
);
128+
}
129+
85130
/**
86131
* _security
87132
* @magentoApiDataFixture Magento/Customer/_files/customer.php

0 commit comments

Comments
 (0)