Skip to content

Commit

Permalink
Merge pull request #874 from Marko-M/bugfix/varnish_esi_src_special_c…
Browse files Browse the repository at this point in the history
…hars

Prevent special characters finding their way into layout handle due to SKU being used (MAGETWO-32349)
  • Loading branch information
maksek committed Jan 6, 2015
2 parents ce71c37 + f62fc68 commit c913c94
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions app/code/Magento/Catalog/Helper/Product/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,26 @@ public function initProductLayout(ResultPage $resultPage, $product, $params = nu
$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
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function _wrapEsi(
'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);
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Review/Controller/Product/ListAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ protected function _initProductLayout($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();
Expand Down

0 comments on commit c913c94

Please sign in to comment.