Skip to content

Commit c179f4d

Browse files
Merge branch 'application-server' of github.com:magento-performance/magento2ce into ACPT-1687
2 parents 396ef20 + 57138e7 commit c179f4d

File tree

5 files changed

+49
-31
lines changed

5 files changed

+49
-31
lines changed

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
*/

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
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ResolverCache/MediaGalleryTest.php

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@ public function testResolverCacheRecordIsCreatedForEachStoreView()
284284
*/
285285
public function testMediaGalleryForProductVideos(callable $actionMechanismCallable, bool $isInvalidationAction)
286286
{
287-
$this->markTestSkipped('Fixing this test in ACPT-1660');
288-
289287
// Test simple product with media
290288
$simpleProductWithMedia = $this->productRepository->get('simple_product_with_media');
291289

@@ -596,24 +594,9 @@ private function assertCacheIdIsNotOrphanedInTagsForProduct(ProductInterface $pr
596594
$cacheLowLevelFrontend = $this->graphQlResolverCache->getLowLevelFrontend();
597595
$cacheIdPrefix = $cacheLowLevelFrontend->getOption('cache_id_prefix');
598596
$cacheBackend = $cacheLowLevelFrontend->getBackend();
599-
600-
$this->assertNotContains(
601-
$cacheIdPrefix . $cacheKey,
602-
$cacheBackend->getIdsMatchingTags([
603-
$cacheIdPrefix . 'GRAPHQL_QUERY_RESOLVER_RESULT'
604-
]),
605-
'Cache id is still present in GRAPHQL_QUERY_RESOLVER_RESULT tag file after invalidation'
606-
);
607-
608-
$this->assertNotContains(
609-
$cacheIdPrefix . $cacheKey,
610-
$cacheBackend->getIdsMatchingTags([
611-
$cacheIdPrefix . 'GQL_MEDIA_GALLERY_' . strtoupper($product->getSku()),
612-
]),
613-
sprintf(
614-
'Cache id is still present in GQL_MEDIA_GALLERY_%s tag file after invalidation',
615-
strtoupper($product->getSku())
616-
)
597+
$this->assertFalse(
598+
$this->graphQlResolverCache->test($cacheIdPrefix . 'GRAPHQL_QUERY_RESOLVER_RESULT'),
599+
'Cache id is still present after invalidation'
617600
);
618601
}
619602

lib/internal/Magento/Framework/App/Cache/State.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
use Magento\Framework\App\DeploymentConfig;
1111
use Magento\Framework\App\DeploymentConfig\Writer;
1212
use Magento\Framework\Config\File\ConfigFilePool;
13+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1314

1415
/**
1516
* Cache State
1617
*/
17-
class State implements StateInterface
18+
class State implements StateInterface, ResetAfterRequestInterface
1819
{
1920
/**
2021
* Disallow cache
@@ -31,28 +32,28 @@ class State implements StateInterface
3132
*
3233
* @var DeploymentConfig
3334
*/
34-
private $config;
35+
private readonly DeploymentConfig $config;
3536

3637
/**
3738
* Deployment configuration storage writer
3839
*
3940
* @var Writer
4041
*/
41-
private $writer;
42+
private readonly Writer $writer;
4243

4344
/**
4445
* Associative array of cache type codes and their statuses (enabled/disabled)
4546
*
46-
* @var array
47+
* @var array|null
4748
*/
48-
private $statuses;
49+
private ?array $statuses = null;
4950

5051
/**
5152
* Whether all cache types are forced to be disabled
5253
*
5354
* @var bool
5455
*/
55-
private $banAll;
56+
private readonly bool $banAll;
5657

5758
/**
5859
* Constructor
@@ -119,4 +120,12 @@ private function load()
119120
$this->statuses = $this->config->getConfigData(self::CACHE_KEY) ?: [];
120121
}
121122
}
123+
124+
/**
125+
* inheritDoc
126+
*/
127+
public function _resetState(): void
128+
{
129+
$this->statuses = null;
130+
}
122131
}

lib/internal/Magento/Framework/TestFramework/ApplicationStateComparator/_files/state-skip-list.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
Magento\Framework\App\Cache\Frontend\Pool::class => null,
4848
Magento\Framework\App\Cache\Type\FrontendPool::class => null,
4949
Magento\Framework\App\DeploymentConfig\Writer::class => null,
50-
Magento\Framework\App\Cache\State::class => null,
5150
Magento\Framework\View\Design\FileResolution\Fallback\TemplateFile::class => null,
5251
Magento\Framework\Module\Dir\Reader::class => null,
5352
Magento\Framework\Module\PackageInfo::class => null,
@@ -399,8 +398,6 @@
399398
Magento\Framework\App\DeploymentConfig::class => null,
400399
Laminas\Uri\Uri::class => null,
401400
Magento\Framework\App\Cache\Frontend\Pool::class => null,
402-
Magento\Framework\App\Cache\State::class =>
403-
null, // TODO: Need to confirm that this gets reset when poison pill triggers
404401
Magento\TestFramework\App\State\Interceptor::class => null,
405402
Magento\TestFramework\App\MutableScopeConfig::class => null,
406403
Magento\TestFramework\Store\StoreManager::class => null,

0 commit comments

Comments
 (0)