Skip to content

Commit 10b1920

Browse files
Merge branch 'application-server' of github.com:magento-performance/magento2ce into application-server
2 parents 6abbd3f + 2cc0a1f commit 10b1920

File tree

35 files changed

+580
-61
lines changed

35 files changed

+580
-61
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\CatalogGraphQl\DataProvider\Product;
7+
8+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
9+
10+
/**
11+
* Builds request specific Product Search Query
12+
*/
13+
class RequestDataBuilder implements ResetAfterRequestInterface
14+
{
15+
private array $data;
16+
17+
public function __construct()
18+
{
19+
$this->_resetState();
20+
}
21+
22+
public function setData($data)
23+
{
24+
$this->data = $data;
25+
}
26+
27+
public function getData(string $key)
28+
{
29+
return $this->data[$key] ?? null;
30+
31+
}
32+
33+
/**
34+
* @inheritDoc
35+
*/
36+
public function _resetState(): void
37+
{
38+
$this->data = [];
39+
}
40+
}

app/code/Magento/CatalogGraphQl/DataProvider/Product/SearchCriteriaBuilder.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ class SearchCriteriaBuilder
6969
*/
7070
private SearchConfig $searchConfig;
7171

72+
private RequestDataBuilder $localData;
73+
7274
/**
7375
* @param Builder $builder
7476
* @param ScopeConfigInterface $scopeConfig
@@ -87,7 +89,8 @@ public function __construct(
8789
Visibility $visibility,
8890
SortOrderBuilder $sortOrderBuilder = null,
8991
Config $eavConfig = null,
90-
SearchConfig $searchConfig = null
92+
SearchConfig $searchConfig = null,
93+
RequestDataBuilder $localData = null,
9194
) {
9295
$this->scopeConfig = $scopeConfig;
9396
$this->filterBuilder = $filterBuilder;
@@ -97,6 +100,7 @@ public function __construct(
97100
$this->sortOrderBuilder = $sortOrderBuilder ?? ObjectManager::getInstance()->get(SortOrderBuilder::class);
98101
$this->eavConfig = $eavConfig ?? ObjectManager::getInstance()->get(Config::class);
99102
$this->searchConfig = $searchConfig ?? ObjectManager::getInstance()->get(SearchConfig::class);
103+
$this->localData = $localData ?? ObjectManager::getInstance()->get(RequestDataBuilder::class);
100104
}
101105

102106
/**
@@ -169,7 +173,7 @@ private function updateMatchTypeRequestConfig(string $requestName, array $partia
169173
}
170174
}
171175
}
172-
$this->searchConfig->merge([$requestName => $data]);
176+
$this->localData->setData([$requestName => $data]);
173177
}
174178

175179
/**

app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/Provider.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99

1010
use Magento\Catalog\Pricing\Price\FinalPrice;
1111
use Magento\Catalog\Pricing\Price\RegularPrice;
12+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1213
use Magento\Framework\Pricing\Amount\AmountInterface;
1314
use Magento\Framework\Pricing\SaleableInterface;
1415

1516
/**
1617
* Provides product prices
1718
*/
18-
class Provider implements ProviderInterface
19+
class Provider implements ProviderInterface, ResetAfterRequestInterface
1920
{
2021
/**
2122
* @var array
@@ -33,6 +34,24 @@ class Provider implements ProviderInterface
3334
RegularPrice::PRICE_CODE => []
3435
];
3536

37+
private readonly array $minimalPriceConstructed;
38+
private readonly array $maximalPriceConstructed;
39+
40+
public function __construct()
41+
{
42+
$this->minimalPriceConstructed = $this->minimalPrice;
43+
$this->maximalPriceConstructed = $this->maximalPrice;
44+
}
45+
46+
/**
47+
* @inheritDoc
48+
*/
49+
public function _resetState(): void
50+
{
51+
$this->minimalPrice = $this->minimalPriceConstructed;
52+
$this->maximalPrice = $this->maximalPriceConstructed;
53+
}
54+
3655
/**
3756
* @inheritdoc
3857
*/
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
namespace Magento\Config\App\Config;
8+
9+
use Magento\Config\App\Config\Type\System;
10+
use Magento\Framework\App\State\ReloadProcessorInterface;
11+
use Magento\Framework\ObjectManagerInterface;
12+
13+
/**
14+
* Config module specific reset state
15+
*/
16+
class ReloadConfig implements ReloadProcessorInterface
17+
{
18+
public function __construct(private readonly System $system)
19+
{}
20+
21+
/**
22+
* Tells the system state to reload itself.
23+
*
24+
* @param ObjectManagerInterface $objectManager
25+
* @return void
26+
*/
27+
public function reloadState(): void
28+
{
29+
$this->system->get();
30+
}
31+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,4 +390,11 @@
390390
<type name="Magento\Framework\App\Cache\TypeList">
391391
<plugin name="warm_config_cache" type="Magento\Config\Plugin\Framework\App\Cache\TypeList\WarmConfigCache"/>
392392
</type>
393+
<type name="Magento\Framework\App\State\ReloadProcessorComposite">
394+
<arguments>
395+
<argument name="processors" xsi:type="array">
396+
<item name="Magento_Config::config" xsi:type="object">Magento\Config\App\Config\ReloadConfig</item>
397+
</argument>
398+
</arguments>
399+
</type>
393400
</config>

app/code/Magento/GraphQlResolverCache/Model/Resolver/Result/ValueProcessor.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99

1010
use Magento\Framework\GraphQl\Query\ResolverInterface;
1111
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
12+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1213
use Magento\Framework\ObjectManagerInterface;
1314
use Magento\GraphQlResolverCache\Model\Resolver\Result\ValueProcessor\FlagSetter\FlagSetterInterface;
1415
use Magento\GraphQlResolverCache\Model\Resolver\Result\ValueProcessor\FlagGetter\FlagGetterInterface;
1516

1617
/**
1718
* Value processor for cached resolver value.
1819
*/
19-
class ValueProcessor implements ValueProcessorInterface
20+
class ValueProcessor implements ValueProcessorInterface, ResetAfterRequestInterface
2021
{
2122
/**
2223
* @var HydratorProviderInterface
@@ -161,4 +162,13 @@ public function preProcessValueBeforeCacheSave(ResolverInterface $resolver, &$va
161162
$dehydrator->dehydrate($value);
162163
}
163164
}
165+
166+
/**
167+
* @inheritDoc
168+
*/
169+
public function _resetState(): void
170+
{
171+
$this->hydrators = [];
172+
$this->processedValues = [];
173+
}
164174
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
namespace Magento\Store\Model\Config;
8+
9+
use Magento\Framework\App\State\ReloadProcessorInterface;
10+
use Magento\Framework\ObjectManagerInterface;
11+
use Magento\Store\App\Config\Type\Scopes;
12+
use Magento\Store\Model\GroupRepository;
13+
use Magento\Store\Model\StoreRepository;
14+
use Magento\Store\Model\WebsiteRepository;
15+
16+
/**
17+
* Store module specific reset state part
18+
*/
19+
class ReloadDeploymentConfig implements ReloadProcessorInterface
20+
{
21+
22+
public function __construct(
23+
private readonly StoreRepository $storeRepository,
24+
private readonly WebsiteRepository $websiteRepository,
25+
private readonly GroupRepository $groupRepository,
26+
private readonly Scopes $scopes
27+
)
28+
{}
29+
30+
/**
31+
* Tells the system state to reload itself.
32+
*
33+
* @param ObjectManagerInterface $objectManager
34+
* @return void
35+
*/
36+
public function reloadState(): void
37+
{
38+
// Note: Magento\Store\Model\StoreManager::reinitStores can't be called because it flushes the caches which
39+
// we don't want to do because that is already taken care of. Instead, we call the same clean methods that
40+
// it calls, but we skip cleaning the cache.
41+
42+
$this->storeRepository->clean();
43+
$this->websiteRepository->clean();
44+
$this->groupRepository->clean();
45+
46+
$this->scopes->clean();
47+
$this->scopes->get();
48+
}
49+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,4 +467,11 @@
467467
</argument>
468468
</arguments>
469469
</type>
470+
<type name="Magento\Framework\App\State\ReloadProcessorComposite">
471+
<arguments>
472+
<argument name="processors" xsi:type="array">
473+
<item name="Magento_ApplicationServer::process" xsi:type="object">Magento\Store\Model\Config\ReloadDeploymentConfig</item>
474+
</argument>
475+
</arguments>
476+
</type>
470477
</config>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
namespace Magento\Translation\App\Config;
8+
9+
use Magento\Framework\App\State\ReloadProcessorInterface;
10+
use Magento\Framework\ObjectManagerInterface;
11+
use Magento\Translation\App\Config\Type\Translation;
12+
13+
/**
14+
* Translation module specific reset state part
15+
*/
16+
class ReloadConfig implements ReloadProcessorInterface
17+
{
18+
/**
19+
* @param Translation $translation
20+
*/
21+
public function __construct(private readonly Translation $translation)
22+
{}
23+
24+
/**
25+
* Tells the system state to reload itself.
26+
*
27+
* @param ObjectManagerInterface $objectManager
28+
* @return void
29+
*/
30+
public function reloadState(): void
31+
{
32+
$this->translation->clean();
33+
}
34+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,11 @@
149149
</argument>
150150
</arguments>
151151
</type>
152+
<type name="Magento\Framework\App\State\ReloadProcessorComposite">
153+
<arguments>
154+
<argument name="processors" xsi:type="array">
155+
<item name="Magento_Translate::config" xsi:type="object">Magento\Translation\App\Config\ReloadConfig</item>
156+
</argument>
157+
</arguments>
158+
</type>
152159
</config>

0 commit comments

Comments
 (0)