8000 adjust session listener to symfony 4.1 by dbu · Pull Request #439 · FriendsOfSymfony/FOSHttpCacheBundle · GitHub
[go: up one dir, main page]

Skip to content

adjust session listener to symfony 4.1 #439

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

Merged
merged 3 commits into from
Apr 14, 2018
Merged

adjust session listener to symfony 4.1 #439

merged 3 commits into from
Apr 14, 2018

Conversation

dbu
Copy link
Contributor
@dbu dbu commented Apr 5, 2018

Use symfony/symfony#26681 to make the session listener work with Symfony 4.1

Fix #437
Replaces #438

@dbu
Copy link
< 10000 /div>
Contributor Author
dbu commented Apr 5, 2018

@Toflar would you have a moment to review this one?

@dbu dbu force-pushed the cache-logged-in-4.1 branch from 592597a to 2cd6ff8 Compare April 5, 2018 08:07
@dbu
Copy link
Contributor Author
dbu commented Apr 5, 2018

@emodric can you also check if this makes sense?

@emodric
Copy link
Contributor
emodric commented Apr 5, 2018

@dbu Looks good to me 👍

Although, I was confused at first at why do you disable the original listener even on versions lower than Symfony 3.4 (if (version_compare(Kernel::VERSION, '4.1', '<'))), but then I remembered that the decorator is only active for Symfony >= 3.4 in a compiler pass. This could be made more explicit maybe: to do the version check in one place.

}

// noop, see class description
// For Symfony 4.1+, we need to call the inner listener to save the session. Set the header to disable overwriting caching headers.
$event->getResponse()->headers->set(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be set here. I think we should not decorate the listener at all in Symfony 4.1+ but instead set that header where it belongs: The UserContextListener. Imho it can always be added, even for lower Symfony versions because the header doesn't harm at all if it is being sent to external but if you really want to omit that you can add the version_compare there.

So basically imho we should only register/decorate this listener when Symfony 3.4 or Symfony 4.0.
And then I think - for the sake of your time and stress level - you should really think about dropping < 4.1 support in the future 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So basically imho we should only register/decorate this listener when Symfony 3.4 or Symfony 4.0.

Yep, this goes inline with my suggestion to keep the version check at one place. It can be further extended to only decorate on Sf 3.4 and 4.0.

And then I think - for the sake of your time and stress level - you should really think about dropping < 4.1 support in the future

I hope this won't happen before 3.0, though :)

@dbu dbu force-pushed the cache-logged-in-4.1 branch from 2cd6ff8 to 1f9d81b Compare April 5, 2018 20:11
@dbu dbu force-pushed the cache-logged-in-4.1 branch from 1f9d81b to c943698 Compare April 5, 2018 20:12
@dbu
Copy link
Contributor Author
dbu commented Apr 5, 2018

thanks for the input. indeed, thats much better. i now add the header in the UserContextListener and the SessionListener is purely a workaround for SF 3.4 and 4.0.

good like this, or any more input?

@emodric
Copy link
Contributor
emodric commented Apr 5, 2018

Looks good! 👍

@Toflar
Copy link
Contributor
Toflar commented Apr 6, 2018

Perfect, yes 👍 Maybe we should add a unit test covering that case in the UserContextListener? Or did you leave that out on purpose because 4.1 is not released yet? 😄

@emodric
Copy link
Contributor
emodric commented Apr 13, 2018

@dbu Is there a chance this might be backported to 1.x branch? Decorator for 3.4 and 4.0, and setting the header for 4.1, that is?

@dbu
Copy link
Contributor Author
dbu commented Apr 13, 2018

got stuck trying to build that test... hope to have something soon.

@emodric i'd rather not maintain the 1.x branch anymore. the 1.3 branch does not support symfony 4. if you really need the 1.3 branch with symfony 3.4 and can't upgrade to FOSHttpCacheBundle 2, i can merge a pull request on the 1.3 branch for this, if you port it. might also safe other people who are stuck on version 1 and update symfony to 3.4.

@emodric
Copy link
Contributor
emodric commented Apr 13, 2018

Thanks! I'll create a PR with the decorator, I would need it for Symfony 3.4, yes.

@dbu dbu force-pushed the cache-logged-in-4.1 branch from 302673c to e2943c9 Compare April 14, 2018 09:26
@dbu dbu force-pushed the cache-logged-in-4.1 branch from e2943c9 to 2a95081 Compare April 14, 2018 09:27
@dbu dbu merged commit 8955f39 into master Apr 14, 2018
@dbu dbu deleted the cache-logged-in-4.1 branch April 14, 2018 09:41
@dbu
Copy link
Contributor Author
dbu commented Apr 16, 2018

tagged as 2.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0