Skip to content

Commit 2dec4df

Browse files
committed
fix: backend article preview 'shop' cookie
1 parent f5256ae commit 2dec4df

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

engine/Shopware/Plugins/Default/Core/Router/Bootstrap.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use Shopware\Models\Shop\Shop;
3030
use Shopware\Models\Shop\Template;
3131
use Symfony\Component\HttpFoundation\Cookie;
32+
use Symfony\Component\HttpFoundation\Response;
3233

3334
class Shopware_Plugins_Core_Router_Bootstrap extends Shopware_Components_Plugin_Bootstrap
3435
{
@@ -53,14 +54,15 @@ public function install()
5354
public function onRouteStartup(Enlight_Controller_EventArgs $args)
5455
{
5556
$request = $args->getRequest();
57+
$response = $args->getResponse();
5658

5759
if (str_starts_with($request->getPathInfo(), '/backend')
5860
|| str_starts_with($request->getPathInfo(), '/api/')
5961
) {
6062
return;
6163
}
6264

63-
$shop = $this->getShopByRequest($request);
65+
$shop = $this->getShopByRequest($request, $response);
6466

6567
if (!$shop->getHost()) {
6668
$shop->setHost($request->getHttpHost());
@@ -306,7 +308,7 @@ protected function upgradeShop($request, $response)
306308
*
307309
* @return Shop
308310
*/
309-
protected function getShopByRequest(Request $request)
311+
protected function getShopByRequest(Request $request, Response $response)
310312
{
311313
$repository = $this->get(ModelManager::class)->getRepository(Shop::class);
312314

@@ -317,6 +319,7 @@ protected function getShopByRequest(Request $request)
317319

318320
if ($shop === null && $request->getCookie('shop') !== null) {
319321
$shop = $repository->getActiveById($request->getCookie('shop'));
322+
$response->headers->clearCookie('shop');
320323
}
321324

322325
if ($shop && $request->getCookie('shop') !== null && $request->getPost('__shop') === null) {

0 commit comments

Comments
 (0)