-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] NativeSessionStorage regenerate
method wrongly sets storage as started
#15799
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
Conversation
The Session Storage should not be flagged as started if `session_regenerate_id` fails. A common use case would be to attempt regeneration before actually starting the session.
This is to avoid flagging the storage as started(done by `loadSession()`) if the regeneration fails. Also, PHP 7 will throw an error if a regeneration is attempted for non-active sessions.
regenerate
wrongly sets storage as startedregenerate
wrongly sets storage as started
regenerate
wrongly sets storage as startedregenerate
method wrongly sets storage as started
Updated title to follow contribution standards. |
👍 |
@@ -195,6 +195,11 @@ public function setName($name) | |||
*/ | |||
public function regenerate($destroy = false, $lifetime = null) | |||
{ | |||
// Cannot regenerate the session ID for non-active sessions. | |||
if ('' === session_id()) { |
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.
PHP 5.4 and newer should use session_status()
. See start()
method.
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.
Fixed!
`session_status()` should be used in PHP >= 5.4 instead of `session_id()`.
👍 |
Status: Reviewed |
Thank you @iambrosi. |
…wrongly sets storage as started (iambrosi) This PR was squashed before being merged into the 2.3 branch (closes #15799). Discussion ---------- [HttpFoundation] NativeSessionStorage `regenerate` method wrongly sets storage as started | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This PR fixes an error when regenerating session IDs for non-active sessions. Right now, the session is flagged as _started_, no matter if the session ID was successfully regenerated or not, making the storage [unable to _start the session_](https://github.com/symfony/symfony/blob/6393ec31690a3ecc73e5f1f7ea2185cda7aba203/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php#L130-L132) later on. This also fixes a future error with PHP 7, which throws an error if a regeneration is attempted for non-active sessions. ``` session_regenerate_id(): Cannot regenerate session id - session is not active ``` Commits ------- 8e6ef9c [HttpFoundation] NativeSessionStorage method wrongly sets storage as started
This PR fixes an error when regenerating session IDs for non-active sessions.
Right now, the session is flagged as started, no matter if the session ID was successfully regenerated or not, making the storage unable to start the session later on.
This also fixes a future error with PHP 7, which throws an error if a regeneration is attempted for non-active sessions.