Skip to content

Commit b9b798f

Browse files
Merge branch 'application-server' of github.com:magento-performance/magento2ce into ACPT-1413
2 parents 9ba543d + 92fa2db commit b9b798f

File tree

91 files changed

+5027
-361
lines changed

Some content is hidden

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

91 files changed

+5027
-361
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,62 @@
1111
*/
1212
namespace Magento\Catalog\Model\Product\Attribute\Source;
1313

14+
use Magento\Directory\Model\CountryFactory;
1415
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
16+
use Magento\Framework\App\Cache\Type\Config;
1517
use Magento\Framework\Data\OptionSourceInterface;
18+
use Magento\Framework\Locale\ResolverInterface;
19+
use Magento\Framework\Serialize\SerializerInterface;
20+
use Magento\Store\Model\StoreManagerInterface;
1621

1722
class Countryofmanufacture extends AbstractSource implements OptionSourceInterface
1823
{
1924
/**
20-
* @var \Magento\Framework\App\Cache\Type\Config
25+
* @var Config
2126
*/
2227
protected $_configCacheType;
2328

2429
/**
25-
* Store manager
26-
*
27-
* @var \Magento\Store\Model\StoreManagerInterface
30+
* @var StoreManagerInterface
2831
*/
2932
protected $_storeManager;
3033

3134
/**
32-
* Country factory
33-
*
34-
* @var \Magento\Directory\Model\CountryFactory
35+
* @var CountryFactory
3536
*/
3637
protected $_countryFactory;
3738

3839
/**
39-
* @var \Magento\Framework\Serialize\SerializerInterface
40+
* @var SerializerInterface
4041
*/
4142
private $serializer;
4243

44+
/**
45+
* @var ResolverInterface
46+
*/
47+
private $localeResolver;
48+
4349
/**
4450
* Construct
4551
*
46-
* @param \Magento\Directory\Model\CountryFactory $countryFactory
47-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
48-
* @param \Magento\Framework\App\Cache\Type\Config $configCacheType
52+
* @param CountryFactory $countryFactory
53+
* @param StoreManagerInterface $storeManager
54+
* @param Config $configCacheType
55+
* @param ResolverInterface $localeResolver
56+
* @param SerializerInterface $serializer
4957
*/
5058
public function __construct(
51-
\Magento\Directory\Model\CountryFactory $countryFactory,
52-
\Magento\Store\Model\StoreManagerInterface $storeManager,
53-
\Magento\Framework\App\Cache\Type\Config $configCacheType
59+
CountryFactory $countryFactory,
60+
StoreManagerInterface $storeManager,
61+
Config $configCacheType,
62+
ResolverInterface $localeResolver,
63+
SerializerInterface $serializer
5464
) {
5565
$this->_countryFactory = $countryFactory;
5666
$this->_storeManager = $storeManager;
5767
$this->_configCacheType = $configCacheType;
68+
$this->localeResolver = $localeResolver;
69+
$this->serializer = $serializer;
5870
}
5971

6072
/**
@@ -64,32 +76,20 @@ public function __construct(
6476
*/
6577
public function getAllOptions()
6678
{
67-
$cacheKey = 'COUNTRYOFMANUFACTURE_SELECT_STORE_' . $this->_storeManager->getStore()->getCode();
79+
$storeCode = $this->_storeManager->getStore()->getCode();
80+
$locale = $this->localeResolver->getLocale();
81+
82+
$cacheKey = 'COUNTRYOFMANUFACTURE_SELECT_STORE_' . $storeCode . '_LOCALE_' . $locale;
6883
if ($cache = $this->_configCacheType->load($cacheKey)) {
69-
$options = $this->getSerializer()->unserialize($cache);
84+
$options = $this->serializer->unserialize($cache);
7085
} else {
7186
/** @var \Magento\Directory\Model\Country $country */
7287
$country = $this->_countryFactory->create();
7388
/** @var \Magento\Directory\Model\ResourceModel\Country\Collection $collection */
7489
$collection = $country->getResourceCollection();
7590
$options = $collection->load()->toOptionArray();
76-
$this->_configCacheType->save($this->getSerializer()->serialize($options), $cacheKey);
91+
$this->_configCacheType->save($this->serializer->serialize($options), $cacheKey);
7792
}
7893
return $options;
7994
}
80-
81-
/**
82-
* Get serializer
83-
*
84-
* @return \Magento\Framework\Serialize\SerializerInterface
85-
* @deprecated 102.0.0
86-
*/
87-
private function getSerializer()
88-
{
89-
if ($this->serializer === null) {
90-
$this->serializer = \Magento\Framework\App\ObjectManager::getInstance()
91-
->get(\Magento\Framework\Serialize\SerializerInterface::class);
92-
}
93-
return $this->serializer;
94-
}
9595
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Catalog\Model\Product\Attribute\Source\Countryofmanufacture;
1111
use Magento\Framework\App\Cache\Type\Config;
12+
use Magento\Framework\Locale\ResolverInterface;
1213
use Magento\Framework\Serialize\SerializerInterface;
1314
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1415
use Magento\Store\Model\Store;
@@ -46,17 +47,24 @@ class CountryofmanufactureTest extends TestCase
4647
*/
4748
private $serializerMock;
4849

50+
/**
51+
* @var ResolverInterface
52+
*/
53+
private $localeResolverMock;
54+
4955
protected function setUp(): void
5056
{
5157
$this->storeManagerMock = $this->getMockForAbstractClass(StoreManagerInterface::class);
5258
$this->storeMock = $this->createMock(Store::class);
5359
$this->cacheConfig = $this->createMock(Config::class);
60+
$this->localeResolverMock = $this->getMockForAbstractClass(ResolverInterface::class);
5461
$this->objectManagerHelper = new ObjectManager($this);
5562
$this->countryOfManufacture = $this->objectManagerHelper->getObject(
5663
Countryofmanufacture::class,
5764
[
5865
'storeManager' => $this->storeManagerMock,
5966
'configCacheType' => $this->cacheConfig,
67+
'localeResolver' => $this->localeResolverMock,
6068
]
6169
);
6270

@@ -80,9 +88,10 @@ public function testGetAllOptions($cachedDataSrl, $cachedDataUnsrl)
8088
{
8189
$this->storeMock->expects($this->once())->method('getCode')->willReturn('store_code');
8290
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock);
91+
$this->localeResolverMock->expects($this->once())->method('getLocale')->willReturn('en_US');
8392
$this->cacheConfig->expects($this->once())
8493
->method('load')
85-
->with($this->equalTo('COUNTRYOFMANUFACTURE_SELECT_STORE_store_code'))
94+
->with($this->equalTo('COUNTRYOFMANUFACTURE_SELECT_STORE_store_code_LOCALE_en_US'))
8695
->willReturn($cachedDataSrl);
8796
$this->serializerMock->expects($this->once())
8897
->method('unserialize')

app/code/Magento/CmsGraphQl/Model/Resolver/Block/ResolverCacheIdentity.php

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

1010
use Magento\Cms\Api\Data\BlockInterface;
1111
use Magento\Cms\Model\Block;
12-
use Magento\Framework\GraphQl\Query\Resolver\IdentityInterface;
12+
use Magento\GraphQlResolverCache\Model\Resolver\Result\Cache\IdentityInterface;
1313

1414
class ResolverCacheIdentity implements IdentityInterface
1515
{
@@ -19,12 +19,9 @@ class ResolverCacheIdentity implements IdentityInterface
1919
private $cacheTag = Block::CACHE_TAG;
2020

2121
/**
22-
* Get block identities from resolved data
23-
*
24-
* @param array $resolvedData
25-
* @return string[]
22+
* @inheritdoc
2623
*/
27-
public function getIdentities(array $resolvedData): array
24+
public function getIdentities($resolvedData, ?array $parentResolvedData = null): array
2825
{
2926
$ids = [];
3027
$items = $resolvedData['items'] ?? [];

app/code/Magento/CmsGraphQl/Model/Resolver/Page/ResolverCacheIdentity.php

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

1010
use Magento\Cms\Api\Data\PageInterface;
1111
use Magento\Cms\Model\Page;
12-
use Magento\Framework\GraphQl\Query\Resolver\IdentityInterface;
12+
use Magento\GraphQlResolverCache\Model\Resolver\Result\Cache\IdentityInterface;
1313

1414
/**
1515
* Identity for resolved CMS page for resolver cache type
@@ -22,12 +22,9 @@ class ResolverCacheIdentity implements IdentityInterface
2222
private $cacheTag = Page::CACHE_TAG;
2323

2424
/**
25-
* Get page ID from resolved data
26-
*
27-
* @param array $resolvedData
28-
* @return string[]
25+
* @inheritdoc
2926
*/
30-
public function getIdentities(array $resolvedData): array
27+
public function getIdentities($resolvedData, ?array $parentResolvedData = null): array
3128
{
3229
return empty($resolvedData[PageInterface::PAGE_ID]) ?
3330
[] : [sprintf('%s_%s', $this->cacheTag, $resolvedData[PageInterface::PAGE_ID])];

app/code/Magento/CmsGraphQl/Test/Integration/Model/Resolver/PageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
use Magento\Framework\App\Cache\Type\FrontendPool;
1515
use Magento\Framework\ObjectManagerInterface;
1616
use Magento\GraphQl\Service\GraphQlRequest;
17-
use Magento\GraphQlCache\Model\Cache\Query\Resolver\Result\Type as GraphQlResolverCache;
18-
use Magento\GraphQlCache\Model\Plugin\Query\Resolver\Result\Cache as ResolverResultCachePlugin;
17+
use Magento\GraphQlResolverCache\Model\Plugin\Resolver\Cache as ResolverResultCachePlugin;
18+
use Magento\GraphQlResolverCache\Model\Resolver\Result\Type as GraphQlResolverCache;
1919
use Magento\TestFramework\Helper\Bootstrap;
2020
use PHPUnit\Framework\TestCase;
2121

app/code/Magento/CmsGraphQl/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"magento/framework": "*",
88
"magento/module-cms": "*",
99
"magento/module-widget": "*",
10-
"magento/module-store": "*"
10+
"magento/module-store": "*",
11+
"magento/module-graph-ql-resolver-cache": "*"
1112
},
1213
"suggest": {
1314
"magento/module-graph-ql": "*",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9-
<type name="Magento\GraphQlCache\Model\Cache\Query\Resolver\Result\TagResolver">
9+
<type name="Magento\GraphQlResolverCache\Model\Resolver\Result\TagResolver">
1010
<arguments>
1111
<argument name="invalidatableObjectTypes" xsi:type="array">
1212
<item name="Magento\Cms\Api\Data\PageInterface" xsi:type="string">

app/code/Magento/CmsGraphQl/etc/graphql/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</argument>
1919
</arguments>
2020
</type>
21-
<type name="Magento\GraphQlCache\Model\Cache\Query\Resolver\Result\ResolverIdentityClassLocator">
21+
<type name="Magento\GraphQlResolverCache\Model\Resolver\Result\ResolverIdentityClassProvider">
2222
<arguments>
2323
<argument name="cacheableResolverClassNameIdentityMap" xsi:type="array">
2424
<item name="Magento\CmsGraphQl\Model\Resolver\Page" xsi:type="string">

app/code/Magento/CmsGraphQl/etc/module.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<module name="Magento_CmsGraphQl">
1010
<sequence>
1111
<module name="Magento_GraphQl"/>
12+
<module name="Magento_GraphQlResolverCache"/>
1213
</sequence>
1314
</module>
1415
</config>

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/summary.js

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,8 @@ define([
135135
if (productId && !images.file) {
136136
images = product.images;
137137
}
138-
productDataFromGrid = _.pick(
139-
productDataFromGrid,
140-
'sku',
141-
'name',
142-
'weight',
143-
'status',
144-
'price',
145-
'qty'
146-
);
138+
productDataFromGrid = this.prepareProductDataFromGrid(productDataFromGrid);
147139

148-
if (productDataFromGrid.hasOwnProperty('qty')) {
149-
productDataFromGrid[this.quantityFieldName] = productDataFromGrid.qty;
150-
}
151-
delete productDataFromGrid.qty;
152140
product = _.pick(
153141
product || {},
154142
'sku',
@@ -288,6 +276,32 @@ define([
288276
* Back.
289277
*/
290278
back: function () {
279+
},
280+
281+
/**
282+
* Prepare product data from grid to have all the current fields values
283+
*
284+
* @param {Object} productDataFromGrid
285+
* @return {Object}
286+
*/
287+
prepareProductDataFromGrid: function (productDataFromGrid) {
288+
productDataFromGrid = _.pick(
289+
productDataFromGrid,
290+
'sku',
291+
'name',
292+
'weight',
293+
'status',
294+
'price',
295+
'qty'
296+
);
297+
298+
if (productDataFromGrid.hasOwnProperty('qty')) {
299+
productDataFromGrid[this.quantityFieldName] = productDataFromGrid.qty;
300+
}
301+
302+
delete productDataFromGrid.qty;
303+
304+
return productDataFromGrid;
291305
}
292306
});
293307
});

0 commit comments

Comments
 (0)