Skip to content

Commit c913c94

Browse files
author
maksek
committed
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)
2 parents ce71c37 + f62fc68 commit c913c94

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Diff for: app/code/Magento/Catalog/Helper/Product/View.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,26 @@ public function initProductLayout(ResultPage $resultPage, $product, $params = nu
116116
$pageConfig->setPageLayout($settings->getPageLayout());
117117
}
118118

119+
$urlSafeSku = rawurlencode($product->getSku());
120+
119121
// Load default page handles and page configurations
120122
if ($params && $params->getBeforeHandles()) {
121123
foreach ($params->getBeforeHandles() as $handle) {
122124
$resultPage->addPageLayoutHandles(
123-
['id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()],
125+
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()],
124126
$handle
125127
);
126128
}
127129
}
128130

129131
$resultPage->addPageLayoutHandles(
130-
['id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()]
132+
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()]
131133
);
132134

133135
if ($params && $params->getAfterHandles()) {
134136
foreach ($params->getAfterHandles() as $handle) {
135137
$resultPage->addPageLayoutHandles(
136-
['id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()],
138+
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()],
137139
$handle
138140
);
139141
}

Diff for: app/code/Magento/PageCache/Model/Observer/ProcessLayoutRenderElement.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected function _wrapEsi(
3737
'page_cache/block/esi',
3838
[
3939
'blocks' => json_encode([$block->getNameInLayout()]),
40-
'handles' => urlencode(json_encode($layout->getUpdate()->getHandles()))
40+
'handles' => json_encode($layout->getUpdate()->getHandles())
4141
]
4242
);
4343
return sprintf('<esi:include src="%s" />', $url);

Diff for: app/code/Magento/Review/Controller/Product/ListAction.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ protected function _initProductLayout($product)
2525
$pageConfig->setPageLayout($product->getPageLayout());
2626
}
2727
$update = $this->_view->getLayout()->getUpdate();
28+
29+
$urlSafeSku = rawurlencode($product->getSku());
2830
$this->_view->addPageLayoutHandles(
29-
['id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()]
31+
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()]
3032
);
3133

3234
$this->_view->loadLayoutUpdates();

0 commit comments

Comments
 (0)