-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Reading from NamespacedAttributeBag adds entries to session #27912
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
This clearly looks a bug. It comes from this line: symfony/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php Line 127 in 3cfdc9e
Pity that we didn't have any appropriate test to spot this bug earlier. if (!$writeContext) {
$null = null;
return $null; // return by reference forces this trick
}
$array[$part] = array(); But I would rather not use I can propose a PR later on with extended tests. Status: Reviewed |
…methods of NamespacedAttributeBag (webnet-fr) This PR was submitted for the 3.4 branch but it was merged into the 2.8 branch instead (closes #27927). Discussion ---------- [HttpFoundation] Suppress side effects in 'get' and 'has' methods of NamespacedAttributeBag | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27912 | License | MIT | Doc PR | - As @Gemineye reported there was a bug in `get` and `has` methods of NamespacedAttributeBag. These methods accept composite names as an argument (like 'foo/bar' or 'foo/bar/baz') to reach the elements of stored arrays. Up to now these methods erroneously created entries (`->get('foo/bar')` created `['foo' => null]`, `->get('foo/bar/baz')` created `['foo' => ['bar' => null]]`). Commits ------- 5f59ad4 suppress side effects in 'get' or 'has' methods of NamespacedAttributeBag
Symfony version(s) affected: 3.4.12
Description
If i call $session->get('foo/bar/name') on a clean session I will end up with data in the session.
In my opinion a "get" should not create any entries.
How to reproduce
$session->get('foo/bar/name');
dump($session->get('foo'));
I would expect to see 'null' but i get an array containing "bar => null"
The text was updated successfully, but these errors were encountered: