diff --git a/vendor/magento/module-page-cache/Model/App/Request/Http/Identifier.php b/vendor/magento/module-page-cache/Model/App/Request/Http/Identifier.php new file mode 100644 index 0000000000000..9cd3965e201af --- /dev/null +++ b/vendor/magento/module-page-cache/Model/App/Request/Http/Identifier.php @@ -0,0 +1,61 @@ +request = $request; + $this->context = $context; + $this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class); + } + + /** + * Return unique page identifier + * + * @return string + */ + public function getValue() + { + $data = [ + $this->request->isSecure(), + $this->request->getUriString(), + $this->request->get(\Magento\Framework\App\Response\Http::COOKIE_VARY_STRING) + ?: $this->context->getVaryString() + ]; + + $data = $this->identifierStoreReader->getPageTagsWithStoreCacheTags($data); + + return sha1($this->serializer->serialize($data)); + } +} diff --git a/vendor/magento/module-page-cache/Model/App/Request/Http/IdentifierForSave.php b/vendor/magento/module-page-cache/Model/App/Request/Http/IdentifierForSave.php index 26b8715c36447..aa31238ecf792 100644 --- a/vendor/magento/module-page-cache/Model/App/Request/Http/IdentifierForSave.php +++ b/vendor/magento/module-page-cache/Model/App/Request/Http/IdentifierForSave.php @@ -23,9 +23,10 @@ class IdentifierForSave implements IdentifierInterface * @param Json $serializer */ public function __construct( - private Http $request, - private Context $context, - private Json $serializer + private Http $request, + private Context $context, + private Json $serializer, + private IdentifierStoreReader $identifierStoreReader, ) { } @@ -42,6 +43,8 @@ public function getValue() $this->context->getVaryString() ]; + $data = $this->identifierStoreReader->getPageTagsWithStoreCacheTags($data); + return sha1($this->serializer->serialize($data)); } } diff --git a/vendor/magento/module-page-cache/Model/App/Request/Http/IdentifierStoreReader.php b/vendor/magento/module-page-cache/Model/App/Request/Http/IdentifierStoreReader.php new file mode 100644 index 0000000000000..b92ce6555d04d --- /dev/null +++ b/vendor/magento/module-page-cache/Model/App/Request/Http/IdentifierStoreReader.php @@ -0,0 +1,67 @@ +designExceptions = $designExceptions; + $this->request = $request; + $this->config = $config; + } + + /** + * Adds a theme key to identifier for a built-in cache if user-agent theme rule is actual + * + * @param \Magento\Framework\App\PageCache\Identifier $identifier + * @param string $result + * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function getPageTagsWithStoreCacheTags($data): ?array + { + if ($this->config->getType() === \Magento\PageCache\Model\Config::BUILT_IN && $this->config->isEnabled()) { + $ruleDesignException = $this->designExceptions->getThemeByRequest($this->request); + if ($ruleDesignException !== false) { + $data['DESIGN'] = $ruleDesignException; + } + + if ($runType = $this->request->getServerValue(StoreManager::PARAM_RUN_TYPE)) { + $data[StoreManager::PARAM_RUN_TYPE] = $runType; + } + + if ($runCode = $this->request->getServerValue(StoreManager::PARAM_RUN_CODE)) { + $data[StoreManager::PARAM_RUN_CODE] = $runCode; + } + } + + return $data; + } +} diff --git a/vendor/magento/module-page-cache/etc/di.xml b/vendor/magento/module-page-cache/etc/di.xml index acaee4b373b0f..038ddfec14caf 100644 --- a/vendor/magento/module-page-cache/etc/di.xml +++ b/vendor/magento/module-page-cache/etc/di.xml @@ -6,10 +6,6 @@ */ --> - - - @@ -48,4 +44,6 @@ + + diff --git a/vendor/magento/module-page-cache/etc/frontend/di.xml b/vendor/magento/module-page-cache/etc/frontend/di.xml index 7f4d05ae206bf..4ef3be3ae8ec9 100644 --- a/vendor/magento/module-page-cache/etc/frontend/di.xml +++ b/vendor/magento/module-page-cache/etc/frontend/di.xml @@ -31,4 +31,15 @@ Magento\PageCache\Model\App\Request\Http\IdentifierForSave + + + + Magento\PageCache\Model\App\Request\Http\IdentifierStoreReader + + + + + Magento\PageCache\Model\App\Request\Http\IdentifierStoreReader + +