Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Session] Add getFlashBag() to SessionInterface#12420

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@znerol
Copy link
Contributor

QA
Bug fix?yes
New feature?no
BC breaks?yes
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR-

@yguedidi
Copy link
Contributor

This is a BC break

@linaori
Copy link
Contributor

It's most likely not going to happen, it has been suggested before. I've already made a PR I find better solution:#11957

You can already use thesession.flash_bag service and inject it. Session as a service will most likely disappear as it is right now in symfony 3.0, check#10557

@znerol
Copy link
ContributorAuthor

Session as a service will most likely disappear as it is right now in symfony 3.0

This is one more reason to have the method on the interface, because then the only way to cleanly get at it is throughRequest::setSession() andRequest::getSession()

@znerol
Copy link
ContributorAuthor

@yguedidi updated the issue summary. Still I'm wondering on the impact of this BC break. Existing third-party session implementations are forced to add a new method, is that the problem?

@yguedidi
Copy link
Contributor

@znerol Yes it is. Maybe they aren't open sources implementations, but maybe they are in closed sources projects.

@linaori
Copy link
Contributor

This is one more reason to have the method on the interface, because then the only way to cleanly get at it is throughRequest::setSession() andRequest::getSession()

There are no concrete plans, but I doubt this will be added as it is.

@znerol
Copy link
ContributorAuthor

I did my share in grepping and pickaxing through the git history. Here is what I found:

The large session refactoring in#2853 introduced theSessionInterface. For some time that interface had a methodgetFlashes() which was removed by commitdad60ef of the pull request. The removal likely happened accidentally because it is clearly visible from the same diff thatSessionHelper used this method to retrieve flash messages. Note thatSessionHelper still happily uses its successorgetFlashBag() in master (without theinstanceof checks shown in the example code of#11957). Other usages are inFrameworkBundle/Controller/Controller.php,WebProfilerBundle/Controller/ProfilerController.php,WebProfilerBundle/EventListener/WebDebugToolbarListener.php,HttpKernel/DataCollector/RequestDataCollector.php.

How likely is it that a third partySessionInterface implementation would even work with Symfony if it would strictly adhere to the interface and leave outgetFlashBag()?

@linaori
Copy link
Contributor

@znerol this was back in 2.1 if I checked correctly. As of 2.3 semver is being followed and BC breaks should be avoided, this is one of those cases.

@znerol
Copy link
ContributorAuthor

@iltar I do not argue that a BC break is okay here because it was fine then. I just want to point out that this was broken from the beginning and that it is still inmaster.

@jakzal
Copy link
Contributor

Duplicate of#11279#10036#5568.

It's not broken, it's like this by design (I'm talking about getFlashBag not being on SessionInterface, not about client code using SessionInterface as if it was a Session). See@Drak's reasoning for rejecting this in the past here:#5568 (comment)

getFlashBag() is just a shortcut method provided by Symfony's implementation of SessionInterface. We don't want to force all the implementations to support flash bags. You can use it Session as a typehint, if you really want to rely on this specific implementation. Otherwise, usegetBag(), which belongs to the interface.

The SessionInterface is technically not tagged with an@api (its methods are), but we try to limit BC breaks as much as possilble.

@znerol
Copy link
ContributorAuthor

How isFrameworkBundle/Controller/Controller.php not broken when it operates onSessionInterface and still wants to usegetFlashBag()?

@linaori
Copy link
Contributor

@znerol that's why you can inject thesession.flash_bag service. I know it's broken and I'd like to see it fixed. But at this moment, theSessionInterface doesn't and shouldn't know about framework specific implementation.

@Tobion
Copy link
Contributor

@znerol FrameworkBundle/Controller/Controller.php does not operate on SessionInterface but on the session service which is configured to behttps://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml#L8

@znerol
Copy link
ContributorAuthor

@Tobion I mentioned other examples as well, e.g.SessionHelper (which retrieves the session from the request and the request is clearly type hinted againstSessionInterface). Also as an exercise for the interested reader: Try to operate any Symfony application with aSession implementation lackinggetFlashBag(). An easy way to do this is simply to remove the method. I guess that in 99% of all cases your application will explode instantly.

@Tobion
Copy link
Contributor

@znerol I agree with you but your example was not ideal. There are also several other design problems I already reported:#9233

@fabpot
Copy link
Member

Closing for the reasons explained by@Tobion.#9233 has all the information we need to move forward. It's now up to someone to think about how to tackle this issue for the next Symfony version.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@znerol@yguedidi@linaori@jakzal@Tobion@fabpot

[8]ページ先頭

©2009-2025 Movatter.jp