-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Session::getBag($name) does not match Storage\SessionStorageInterface::getBag($name) #30682
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
Comments
i think we should test for probably it's intended to use |
@ro0NL what do you mean ? |
There's a difference between registering a bag on the storage vs. on the session. When registering a bag on the session it get's wrapped: symfony/src/Symfony/Component/HttpFoundation/Session/Session.php Lines 246 to 249 in 3bbf9da
When you register thru So i propose in return $bag instanceof SessionBagProxy ? $bag->getBag() : $bag; |
Ok I understand now ! I think that’s a good idea ! I think the only way to
be sure is by making a PR and see of people agree with you ;). ( I do)
Le sam. 22 juin 2019 à 06:00, Roland Franssen <notifications@github.com> a
écrit :
… There's a difference between registering a bag on the storage vs. on the
session.
When registering a bag on the session it get's wrapped:
https://github.com/symfony/symfony/blob/3bbf9da47bdf79d175f84a9a9c73a5d7d4f66beb/src/Symfony/Component/HttpFoundation/Session/Session.php#L246-L249
When you register thru MockArraySessionStorage it's not wrapped, however
we call getBag($name)->getBag() from the Session which at this points
expects a wrapped bag.
So i propose in Session::getBag() something like
return $bag instanceof SessionBagProxy ? $bag->getBag() : $bag;
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#30682?email_source=notifications&email_token=AA2KV4QAXZB7GUUPXBP7RDLP3WPV3A5CNFSM4HA2YE5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYJ7SXA#issuecomment-504625500>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA2KV4XK5R34EUHZZGCBNNDP3WPV3ANCNFSM4HA2YE5A>
.
|
I agree with the reasoning here, see #32137 |
This PR was merged into the 3.4 branch. Discussion ---------- [HttpFoundation] fix accessing session bags | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #30682 | License | MIT | Doc PR | Commits ------- 7a4570d fix accessing session bags
Symfony version(s) affected: 3.4.0 and higher
Description
There is
getBag
method atSymfony\Component\HttpFoundation\Session
which calls$this->storage->getBag($name)->getBag()
.As defined in constructor
$this->storage
is instance ofSymfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface
which contains methodgetBag(string $name)
. As defined in comment it is expected thatSessionStorageInterface::getBag(string $name)
should return instance ofSymfony\Component\HttpFoundation\Session\SessionBagInterface
.The problem is that
SessionBagInterface
does not containgetBag
method so it's impossible to expect that$this->storage->getBag($name)
will return object containinggetBag()
method.How to reproduce
Possible Solution
I'm not sure, probably removing second
getBag
call fromSession::getBag($name)
.The text was updated successfully, but these errors were encountered: