Skip to content

Commit 2117252

Browse files
Merge pull request #8392 from magento-cia/cia-2.4.7-beta2-develop-bugfix-07102023
cia-2.4.7-beta2-develop-bugfix-07102023
2 parents 766f08e + 8e0e728 commit 2117252

File tree

5 files changed

+36
-12
lines changed

5 files changed

+36
-12
lines changed

app/code/Magento/PageCache/Controller/Block.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
declare(strict_types=1);
8+
79
namespace Magento\PageCache\Controller;
810

911
use Magento\Framework\Serialize\Serializer\Base64Json;
1012
use Magento\Framework\Serialize\Serializer\Json;
1113
use Magento\Framework\Validator\RegexFactory;
1214
use Magento\Framework\App\ObjectManager;
1315
use Magento\Framework\View\Layout\LayoutCacheKeyInterface;
16+
use Magento\Framework\App\Config\ScopeConfigInterface;
1417

1518
abstract class Block extends \Magento\Framework\App\Action\Action
1619
{
@@ -51,21 +54,33 @@ abstract class Block extends \Magento\Framework\App\Action\Action
5154
*/
5255
private const VALIDATION_RULE_PATTERN = '/^[a-z0-9]+[a-z0-9_]*$/i';
5356

57+
/**
58+
* @var ScopeConfigInterface
59+
*/
60+
private $config;
61+
62+
/**
63+
* Handle size system name
64+
*/
65+
private const XML_HANDLES_SIZE = 'system/full_page_cache/handles_size';
66+
5467
/**
5568
* @param \Magento\Framework\App\Action\Context $context
5669
* @param \Magento\Framework\Translate\InlineInterface $translateInline
5770
* @param Json $jsonSerializer
5871
* @param Base64Json $base64jsonSerializer
5972
* @param LayoutCacheKeyInterface $layoutCacheKey
6073
* @param RegexFactory|null $regexValidatorFactory
74+
* @param ScopeConfigInterface|null $scopeConfig
6175
*/
6276
public function __construct(
6377
\Magento\Framework\App\Action\Context $context,
6478
\Magento\Framework\Translate\InlineInterface $translateInline,
6579
Json $jsonSerializer = null,
6680
Base64Json $base64jsonSerializer = null,
6781
LayoutCacheKeyInterface $layoutCacheKey = null,
68-
?RegexFactory $regexValidatorFactory = null
82+
?RegexFactory $regexValidatorFactory = null,
83+
ScopeConfigInterface $scopeConfig = null
6984
) {
7085
parent::__construct($context);
7186
$this->translateInline = $translateInline;
@@ -77,6 +92,7 @@ public function __construct(
7792
?: ObjectManager::getInstance()->get(LayoutCacheKeyInterface::class);
7893
$this->regexValidatorFactory = $regexValidatorFactory
7994
?: ObjectManager::getInstance()->get(RegexFactory::class);
95+
$this->config = $scopeConfig;
8096
}
8197

8298
/**
@@ -94,6 +110,11 @@ protected function _getBlocks()
94110
}
95111
$blocks = $this->jsonSerializer->unserialize($blocks);
96112
$handles = $this->base64jsonSerializer->unserialize($handles);
113+
114+
$handleSize = (int) $this->config->getValue(self::XML_HANDLES_SIZE);
115+
$handles = ($handleSize && count($handles) > $handleSize)
116+
? array_splice($handles, 0, $handleSize) : $handles;
117+
97118
if (!$this->validateHandleParam($handles)) {
98119
return [];
99120
}

app/code/Magento/PageCache/etc/adminhtml/system.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@
7878
<comment>Public content cache lifetime in seconds. If field is empty default value 86400 will be saved. </comment>
7979
<backend_model>Magento\PageCache\Model\System\Config\Backend\Ttl</backend_model>
8080
</field>
81+
<field id="handles_size" type="text" translate="label comment" sortOrder="5" showInDefault="1" canRestore="1">
82+
<label>Handles params size</label>
83+
<comment>Handles params size. For better performance use handles parameter size between 50 and 100. </comment>
84+
</field>
8185
</group>
8286
</section>
8387
</system>

app/code/Magento/PageCache/etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<path>varnish4.vcl</path>
2525
</varnish4>
2626
<ttl>86400</ttl>
27+
<handles_size>100</handles_size>
2728
<caching_application>1</caching_application>
2829
<default>
2930
<access_list>localhost</access_list>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<type name="Magento\PageCache\Controller\Block">
3636
<arguments>
3737
<argument name="layoutCacheKey" xsi:type="object">Magento\Framework\View\Layout\LayoutCacheKeyInterface</argument>
38+
<argument name="scopeConfig" xsi:type="object">Magento\Framework\App\Config\ScopeConfigInterface\Proxy</argument>
3839
</arguments>
3940
</type>
4041
<type name="Magento\Framework\App\Cache\RuntimeStaleCacheStateModifier">

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,21 +1933,18 @@ public function testFilterProductsBySingleCategoryId(string $fieldName, string $
19331933
$product = $this->productRepository->get($links[$itemIndex]->getSku());
19341934
$this->assertEquals($response['products']['items'][$itemIndex]['name'], $product->getName());
19351935
$this->assertEquals($response['products']['items'][$itemIndex]['type_id'], $product->getTypeId());
1936-
$categoryIds = $product->getCategoryIds();
1937-
foreach ($categoryIds as $index => $value) {
1938-
$categoryIds[$index] = (int)$value;
1939-
}
1940-
$categoryInResponse = array_map(
1941-
null,
1942-
$categoryIds,
1936+
$categoryIds = array_map('intval', $product->getCategoryIds());
1937+
$this->assertCount(count($categoryIds), $response['products']['items'][$itemIndex]['categories']);
1938+
$categoryInResponse = array_combine(
1939+
array_column($response['products']['items'][$itemIndex]['categories'], 'id'),
19431940
$response['products']['items'][$itemIndex]['categories']
19441941
);
1945-
foreach ($categoryInResponse as $key => $categoryData) {
1946-
$this->assertNotEmpty($categoryData);
1942+
foreach ($categoryIds as $categoryId) {
1943+
$this->assertArrayHasKey($categoryId, $categoryInResponse);
19471944
/** @var CategoryInterface | Category $category */
1948-
$category = $this->categoryRepository->get($categoryInResponse[$key][0]);
1945+
$category = $this->categoryRepository->get($categoryId);
19491946
$this->assertResponseFields(
1950-
$categoryInResponse[$key][1],
1947+
$categoryInResponse[$categoryId],
19511948
[
19521949
'name' => $category->getName(),
19531950
'id' => $category->getId(),

0 commit comments

Comments
 (0)