Skip to content

Commit 4ac233f

Browse files
Merge branch '2.4-develop' into functional-mainline-pr-ce-new
2 parents bdf0bd4 + 87d2563 commit 4ac233f

File tree

97 files changed

+1822
-799
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1822
-799
lines changed

app/code/Magento/BundleGraphQl/Model/Cart/BuyRequest/BundleDataProvider.php

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

88
namespace Magento\BundleGraphQl\Model\Cart\BuyRequest;
99

10+
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\Stdlib\ArrayManager;
12+
use Magento\Framework\Stdlib\ArrayManagerFactory;
1113
use Magento\QuoteGraphQl\Model\Cart\BuyRequest\BuyRequestDataProviderInterface;
1214

1315
/**
@@ -16,17 +18,23 @@
1618
class BundleDataProvider implements BuyRequestDataProviderInterface
1719
{
1820
/**
19-
* @var ArrayManager
21+
* @var ArrayManagerFactory
22+
* phpcs:disable Magento2.Commenting.ClassPropertyPHPDocFormatting
2023
*/
21-
private $arrayManager;
24+
private readonly ArrayManagerFactory $arrayManagerFactory;
2225

2326
/**
24-
* @param ArrayManager $arrayManager
27+
* @param ArrayManager $arrayManager @deprecated @see $arrayManagerFactory
28+
* @param ArrayManagerFactory|null $arrayManagerFactory
29+
*
30+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2531
*/
2632
public function __construct(
27-
ArrayManager $arrayManager
33+
ArrayManager $arrayManager,
34+
?ArrayManagerFactory $arrayManagerFactory = null,
2835
) {
29-
$this->arrayManager = $arrayManager;
36+
$this->arrayManagerFactory = $arrayManagerFactory
37+
?? ObjectManager::getInstance()->get(ArrayManagerFactory::class);
3038
}
3139

3240
/**
@@ -35,7 +43,7 @@ public function __construct(
3543
public function execute(array $cartItemData): array
3644
{
3745
$bundleOptions = [];
38-
$bundleInputs = $this->arrayManager->get('bundle_options', $cartItemData) ?? [];
46+
$bundleInputs = $this->arrayManagerFactory->create()->get('bundle_options', $cartItemData) ?? [];
3947
foreach ($bundleInputs as $bundleInput) {
4048
$bundleOptions['bundle_option'][$bundleInput['id']] = $bundleInput['value'];
4149
$bundleOptions['bundle_option_qty'][$bundleInput['id']] = $bundleInput['quantity'];

app/code/Magento/Catalog/Model/Category/AttributeRepository.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
namespace Magento\Catalog\Model\Category;
77

88
use Magento\Catalog\Api\CategoryAttributeRepositoryInterface;
9+
use Magento\Framework\App\State\ReloadProcessorInterface;
910

10-
class AttributeRepository implements CategoryAttributeRepositoryInterface
11+
class AttributeRepository implements CategoryAttributeRepositoryInterface, ReloadProcessorInterface
1112
{
1213
/**
1314
* @var \Magento\Framework\Api\SearchCriteriaBuilder
@@ -30,7 +31,7 @@ class AttributeRepository implements CategoryAttributeRepositoryInterface
3031
private $eavConfig;
3132

3233
/**
33-
* @var array
34+
* @var array|null
3435
*/
3536
private $metadataCache;
3637

@@ -98,4 +99,14 @@ public function getCustomAttributesMetadata($dataObjectClassName = null)
9899
}
99100
return $this->metadataCache[$dataObjectClassName];
100101
}
102+
103+
/**
104+
* @inheritDoc
105+
*/
106+
public function reloadState(): void
107+
{
108+
$this->filterBuilder->_resetState();
109+
$this->searchCriteriaBuilder->_resetState();
110+
$this->metadataCache = null;
111+
}
101112
}

app/code/Magento/Catalog/Model/Product/Type.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Catalog\Model\Product\Type\Simple;
1313
use Magento\Catalog\Model\ProductTypes\ConfigInterface;
1414
use Magento\Framework\Data\OptionSourceInterface;
15+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1516
use Magento\Framework\Pricing\PriceInfo\Factory as PriceInfoFactory;
1617

1718
/**
@@ -21,19 +22,19 @@
2122
* @api
2223
* @since 100.0.2
2324
*/
24-
class Type implements OptionSourceInterface
25+
class Type implements OptionSourceInterface, ResetAfterRequestInterface
2526
{
26-
const TYPE_SIMPLE = 'simple';
27+
public const TYPE_SIMPLE = 'simple';
2728

28-
const TYPE_BUNDLE = 'bundle';
29+
public const TYPE_BUNDLE = 'bundle';
2930

30-
const TYPE_VIRTUAL = 'virtual';
31+
public const TYPE_VIRTUAL = 'virtual';
3132

32-
const DEFAULT_TYPE = 'simple';
33+
public const DEFAULT_TYPE = 'simple';
3334

34-
const DEFAULT_TYPE_MODEL = Simple::class;
35+
public const DEFAULT_TYPE_MODEL = Simple::class;
3536

36-
const DEFAULT_PRICE_MODEL = Price::class;
37+
public const DEFAULT_PRICE_MODEL = Price::class;
3738

3839
/**
3940
* @var ConfigInterface
@@ -55,9 +56,7 @@ class Type implements OptionSourceInterface
5556
protected $_compositeTypes;
5657

5758
/**
58-
* Price models
59-
*
60-
* @var array
59+
* @var array|null|Price
6160
*/
6261
protected $_priceModels;
6362

@@ -107,6 +106,14 @@ public function __construct(
107106
$this->_priceInfoFactory = $priceInfoFactory;
108107
}
109108

109+
/**
110+
* @inheritDoc
111+
*/
112+
public function _resetState(): void
113+
{
114+
$this->_priceModels = null;
115+
}
116+
110117
/**
111118
* Factory to product singleton product type instances
112119
*
@@ -136,7 +143,7 @@ public function factory($product)
136143
* Product type price model factory
137144
*
138145
* @param string $productType
139-
* @return \Magento\Catalog\Model\Product\Type\Price
146+
* @return Price
140147
*/
141148
public function priceFactory($productType)
142149
{

app/code/Magento/Catalog/Model/ResourceModel/Product.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,5 +854,9 @@ public function _resetState(): void
854854
{
855855
parent::_resetState();
856856
$this->availableCategoryIdsCache = [];
857+
$this->_type = null;
858+
$this->_entityTable = null;
859+
$this->_entityIdField = null;
860+
$this->linkIdField = null;
857861
}
858862
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Webapi/Rest/RequestTypeBasedDeserializerTest.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@
77
namespace Magento\Catalog\Test\Unit\Model\Product\Webapi\Rest;
88

99
use Magento\Catalog\Model\Product\Webapi\Rest\RequestTypeBasedDeserializer;
10-
use Magento\Framework\Webapi\Rest\Request\DeserializerFactory;
11-
use Magento\Framework\Webapi\Rest\Request;
12-
use PHPUnit\Framework\MockObject\MockObject;
13-
use Magento\Framework\Webapi\Rest\Request\DeserializerInterface;
14-
use Magento\Framework\Webapi\Rest\Request\Deserializer\Json as DeserializerJson;
15-
use Magento\Framework\Webapi\Rest\Request\Deserializer\Xml as DeserializerXml;
1610
use Magento\Framework\App\State;
1711
use Magento\Framework\Json\Decoder;
1812
use Magento\Framework\Serialize\Serializer\Json as SerializerJson;
13+
use Magento\Framework\Webapi\Rest\Request;
14+
use Magento\Framework\Webapi\Rest\Request\Deserializer\Json as DeserializerJson;
15+
use Magento\Framework\Webapi\Rest\Request\Deserializer\Xml as DeserializerXml;
16+
use Magento\Framework\Webapi\Rest\Request\DeserializerFactory;
17+
use Magento\Framework\Webapi\Rest\Request\DeserializerInterface;
1918
use Magento\Framework\Xml\Parser as ParserXml;
19+
use Magento\Framework\Xml\ParserFactory as ParserXmlFactory;
20+
use PHPUnit\Framework\MockObject\MockObject;
2021

22+
/**
23+
* A Test for RequestTypeBasedDeserializer
24+
*
25+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26+
*/
2127
class RequestTypeBasedDeserializerTest extends \PHPUnit\Framework\TestCase
2228
{
2329
/** @var RequestTypeBasedDeserializer */
@@ -146,6 +152,8 @@ private function prepareXmlDeserializer(): DeserializerXml
146152
$parserXml = new ParserXml();
147153
/** @var State|MockObject $appStateMock */
148154
$appStateMock = $this->createMock(State::class);
149-
return new DeserializerXml($parserXml, $appStateMock);
155+
$parserXmlFactoryMock = $this->createMock(ParserXmlFactory::class);
156+
$parserXmlFactoryMock->method('create')->willReturn($parserXml);
157+
return new DeserializerXml($parserXml, $appStateMock, $parserXmlFactoryMock);
150158
}
151159
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,4 +1344,11 @@
13441344
</argument>
13451345
</arguments>
13461346
</type>
1347+
<type name="Magento\Framework\App\State\ReloadProcessorComposite">
1348+
<arguments>
1349+
<argument name="processors" xsi:type="array">
1350+
<item name="Magento_Catalog::AttributeRepository" xsi:type="object">Magento\Catalog\Model\Category\AttributeRepository</item>
1351+
</argument>
1352+
</arguments>
1353+
</type>
13471354
</config>

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,16 @@
397397
</argument>
398398
</arguments>
399399
</type>
400+
<!-- TODO: Move these to Framework's di.xml after issue with array_replace_recursive in configuration are resolved.
401+
-->
402+
<type name="Magento\Framework\ObjectManager\Resetter\WeakMapSorter">
403+
<arguments>
404+
<argument name="sortOrder" xsi:type="array">
405+
<item name="Magento\Framework\Session\SessionManagerInterface" xsi:type="number">1000</item>
406+
<item name="Magento\Framework\App\Cache\State" xsi:type="number">10000</item>
407+
<item name="Magento\Framework\DB\Logger\LoggerProxy" xsi:type="number">9999</item>
408+
<item name="Magento\Framework\DB\Adapter\Pdo\Mysql" xsi:type="number">9999</item>
409+
</argument>
410+
</arguments>
411+
</type>
400412
</config>

app/code/Magento/ConfigurableProductGraphQl/Model/Cart/BuyRequest/SuperAttributeDataProvider.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,30 @@
1212
use Magento\CatalogInventory\Api\StockStateInterface;
1313
use Magento\CatalogInventory\Model\StockStateException;
1414
use Magento\ConfigurableProductGraphQl\Model\Options\Collection as OptionCollection;
15+
use Magento\Framework\App\ObjectManager;
1516
use Magento\Framework\EntityManager\MetadataPool;
1617
use Magento\Framework\Exception\LocalizedException;
1718
use Magento\Framework\Exception\NoSuchEntityException;
1819
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1920
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
2021
use Magento\Framework\Stdlib\ArrayManager;
22+
use Magento\Framework\Stdlib\ArrayManagerFactory;
2123
use Magento\Quote\Model\Quote;
2224
use Magento\QuoteGraphQl\Model\Cart\BuyRequest\BuyRequestDataProviderInterface;
2325

2426
/**
2527
* DataProvider for building super attribute options in buy requests
28+
*
29+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2630
*/
2731
class SuperAttributeDataProvider implements BuyRequestDataProviderInterface
2832
{
2933
/**
30-
* @var ArrayManager
34+
* @var ArrayManagerFactory
35+
*
36+
* phpcs:disable Magento2.Commenting.ClassPropertyPHPDocFormatting
3137
*/
32-
private $arrayManager;
38+
private readonly ArrayManagerFactory $arrayManagerFactory;
3339

3440
/**
3541
* @var ProductRepositoryInterface
@@ -52,20 +58,24 @@ class SuperAttributeDataProvider implements BuyRequestDataProviderInterface
5258
private $stockState;
5359

5460
/**
55-
* @param ArrayManager $arrayManager
61+
* @param ArrayManager $arrayManager @deprecated @see $arrayManagerFactory
5662
* @param ProductRepositoryInterface $productRepository
5763
* @param OptionCollection $optionCollection
5864
* @param MetadataPool $metadataPool
5965
* @param StockStateInterface $stockState
66+
* @param ArrayManagerFactory|null $arrayManagerFactory
67+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6068
*/
6169
public function __construct(
6270
ArrayManager $arrayManager,
6371
ProductRepositoryInterface $productRepository,
6472
OptionCollection $optionCollection,
6573
MetadataPool $metadataPool,
66-
StockStateInterface $stockState
74+
StockStateInterface $stockState,
75+
?ArrayManagerFactory $arrayManagerFactory = null,
6776
) {
68-
$this->arrayManager = $arrayManager;
77+
$this->arrayManagerFactory = $arrayManagerFactory
78+
?? ObjectManager::getInstance()->get(ArrayManagerFactory::class);
6979
$this->productRepository = $productRepository;
7080
$this->optionCollection = $optionCollection;
7181
$this->metadataPool = $metadataPool;
@@ -77,13 +87,13 @@ public function __construct(
7787
*/
7888
public function execute(array $cartItemData): array
7989
{
80-
$parentSku = $this->arrayManager->get('parent_sku', $cartItemData);
90+
$parentSku = $this->arrayManagerFactory->create()->get('parent_sku', $cartItemData);
8191
if ($parentSku === null) {
8292
return [];
8393
}
84-
$sku = $this->arrayManager->get('data/sku', $cartItemData);
85-
$qty = $this->arrayManager->get('data/quantity', $cartItemData);
86-
$cart = $this->arrayManager->get('model', $cartItemData);
94+
$sku = $this->arrayManagerFactory->create()->get('data/sku', $cartItemData);
95+
$qty = $this->arrayManagerFactory->create()->get('data/quantity', $cartItemData);
96+
$cart = $this->arrayManagerFactory->create()->get('model', $cartItemData);
8797
if (!$cart instanceof Quote) {
8898
throw new LocalizedException(__('"model" value should be specified'));
8999
}

app/code/Magento/ConfigurableProductGraphQl/Test/Unit/Model/Cart/BuyRequest/SuperAttributeDataProviderTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616
use Magento\Framework\EntityManager\EntityMetadataInterface;
1717
use Magento\Framework\EntityManager\MetadataPool;
1818
use Magento\Framework\Stdlib\ArrayManager;
19+
use Magento\Framework\Stdlib\ArrayManagerFactory;
1920
use Magento\Quote\Model\Quote;
2021
use Magento\Store\Model\Store;
2122
use PHPUnit\Framework\MockObject\MockObject;
2223
use PHPUnit\Framework\TestCase;
2324

2425
/**
2526
* Test for SuperAttributeDataProvider
27+
*
28+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2629
*/
2730
class SuperAttributeDataProviderTest extends TestCase
2831
{
@@ -66,13 +69,15 @@ protected function setUp(): void
6669
$this->optionCollection = $this->createMock(OptionCollection::class);
6770
$this->metadataPool = $this->createMock(MetadataPool::class);
6871
$this->stockState = $this->createMock(StockStateInterface::class);
69-
72+
$arrayManagerFactory = $this->createMock(ArrayManagerFactory::class);
73+
$arrayManagerFactory->method('create')->willReturn($this->arrayManager);
7074
$this->superAttributeDataProvider = new SuperAttributeDataProvider(
7175
$this->arrayManager,
7276
$this->productRepository,
7377
$this->optionCollection,
7478
$this->metadataPool,
75-
$this->stockState
79+
$this->stockState,
80+
$arrayManagerFactory,
7681
);
7782
}
7883

@@ -150,7 +155,6 @@ public function testExecute(): void
150155
'values' => [['value_index' => 1]],
151156
]
152157
]);
153-
154158
$this->assertEquals(['super_attribute' => [1 => 1]], $this->superAttributeDataProvider->execute($cartItemData));
155159
}
156160
}

0 commit comments

Comments
 (0)