44 * Copyright © Magento, Inc. All rights reserved.
55 * See COPYING.txt for license details.
66 */
7+ declare (strict_types=1 );
8+
79namespace Magento \PageCache \Controller ;
810
911use Magento \Framework \Serialize \Serializer \Base64Json ;
1012use Magento \Framework \Serialize \Serializer \Json ;
1113use Magento \Framework \Validator \RegexFactory ;
1214use Magento \Framework \App \ObjectManager ;
1315use Magento \Framework \View \Layout \LayoutCacheKeyInterface ;
16+ use Magento \Framework \App \Config \ScopeConfigInterface ;
1417
1518abstract 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 }
0 commit comments