Skip to content
Snippets Groups Projects
Commit c913c94d authored by maksek's avatar maksek
Browse files

Merge pull request #874 from Marko-M/bugfix/varnish_esi_src_special_chars

Prevent special characters finding their way into layout handle due to SKU being used (MAGETWO-32349)
parents ce71c378 f62fc68d
Branches
No related merge requests found
......@@ -116,24 +116,26 @@ class View extends \Magento\Framework\App\Helper\AbstractHelper
$pageConfig->setPageLayout($settings->getPageLayout());
}
$urlSafeSku = rawurlencode($product->getSku());
// Load default page handles and page configurations
if ($params && $params->getBeforeHandles()) {
foreach ($params->getBeforeHandles() as $handle) {
$resultPage->addPageLayoutHandles(
['id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()],
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()],
$handle
);
}
}
$resultPage->addPageLayoutHandles(
['id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()]
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()]
);
if ($params && $params->getAfterHandles()) {
foreach ($params->getAfterHandles() as $handle) {
$resultPage->addPageLayoutHandles(
['id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()],
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()],
$handle
);
}
......
......@@ -37,7 +37,7 @@ class ProcessLayoutRenderElement
'page_cache/block/esi',
[
'blocks' => json_encode([$block->getNameInLayout()]),
'handles' => urlencode(json_encode($layout->getUpdate()->getHandles()))
'handles' => json_encode($layout->getUpdate()->getHandles())
]
);
return sprintf('<esi:include src="%s" />', $url);
......
......@@ -25,8 +25,10 @@ class ListAction extends \Magento\Review\Controller\Product
$pageConfig->setPageLayout($product->getPageLayout());
}
$update = $this->_view->getLayout()->getUpdate();
$urlSafeSku = rawurlencode($product->getSku());
$this->_view->addPageLayoutHandles(
['id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()]
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()]
);
$this->_view->loadLayoutUpdates();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment