-
Notifications
You must be signed in to change notification settings - Fork 804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: backend article preview 'shop' cookie #2737
base: 5.7
Are you sure you want to change the base?
Conversation
|
this looks like a "hacky" workaround, and not really like a solution to the problem 😬 |
I would have to dig deeper into the code, but if I remember correctly the cookie is only used, to select the current shop from the cookie. I hope, that no one is relying on it 🙈 your change is also breaking, just after 30 seconds 😁 |
@Dominikrt any news on this? |
4b08d26
to
2dec4df
Compare
Hi @mitelg, But I don't know if there is a better way doing this. |
@@ -317,6 +319,7 @@ protected function getShopByRequest(Request $request) | |||
|
|||
if ($shop === null && $request->getCookie('shop') !== null) { | |||
$shop = $repository->getActiveById($request->getCookie('shop')); | |||
$response->headers->clearCookie('shop'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clearing the cookie here, would also affect the next if condition, if I see that correctly.
Before your change, the if condition could also be met, if this condition was met before.
With your change this is no longer possible.
A test of the \Shopware_Plugins_Core_Router_Bootstrap::onRouteStartup
method in \Shopware\Tests\Functional\Plugins\Core\Router\BootstrapTest
would be really nice, to ensure, that we do not break stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, the main problem is, I don't understand the reason of this cookie.
I tested this change on my server and I still get redirect after the first attempt, trying to visit the start page. Only on the second attempt is the Cookie gone and I can visit the primary shop again.
But I don't know, if there is a case that the cookie is needed to redirect to the right shop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need the cookie at all then? 🤔
unfortunately I cannot reproduce this locally. you wrote this only occurs via HTTPS? 🤔 If I am using only HTTP, the cookie is not set at all 🤔
@Dominikrt thanks! this looks better to me, but still a little question mark 😁 |
2dec4df
to
7534ab0
Compare
$pluginBootstrap->onRouteStartup($args); | ||
|
||
static::assertSame(Response::HTTP_OK, $response->getStatusCode()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mitelg, here 2 options for testing this, I'm not happy with both solutions
1. Why is this change necessary?
If you have a subshop with a different domain and click on the preview button in the backend, you are no longer able to visit the main shop on the main domain. You get redirected to the subshop all the time.
2. What does this change do, exactly?
The
shop
cookie get a ttl from 30 seconds. after this time you can visit the main shop again.3. Describe each step to reproduce the issue or behaviour.
Setup a subshop with a different domain and show the preview of an article in this subshop. you are no longer able to visit the main shop.
This bug works only over https!
4. Please link to the relevant issues (if any).
5. Which documentation changes (if any) need to be made because of this PR?
6. Checklist