-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Fix invalid ID not regenerated with native PHP file sessions #47130
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
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.
Thank you for your PR. Would it be possible to add a test that reproduces the bug you're attempting to fix? I'd like to make sure we don't reintroduce it in the future.
src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php
Show resolved
Hide resolved
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.
LGTM, here are some final notes
src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php
Show resolved
Hide resolved
src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
Outdated
Show resolved
Hide resolved
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.
Maybe we should use a more intuitive name for the method? Like isInternalWrapper
, wrapsInternalHandler
, hasInternalHandler
. What do you think @nicolas-grekas? In my opinion, this makes the method more understandable.
/**
* Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.
*
* @internal
*/
- public function isWrapper(): bool
+ public function isInternalWrapper(): bool
{
return $this->handler instanceof \SessionHandler;
}
/**
* Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.
*
* @internal
*/
- public function isWrapper(): bool
+ public function wrapsInternalHandler(): bool
{
return $this->handler instanceof \SessionHandler;
}
/**
* Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.
*
* @internal
*/
- public function isWrapper(): bool
+ public function hasInternalHandler(): bool
{
return $this->handler instanceof \SessionHandler;
}
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.
I'm fine with isWrapper: this is what AbstractProxy uses already for the same thing
Thank you @brokensourcecode. |
Inside the
SessionHandlerProxy
class, the code defines$this->saveHandlerName
to\ini_get('session.save_handler')
when$handler
is an instance of\SessionHandler
.symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php
Lines 24 to 25 in 818d4dd
But inside the
NativeSessionStorage
class, the code create an instance ofStrictSessionHandler
that doesn't inherit from\SessionHandler
and is passed to theSessionHandlerProxy
constructor.symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php
Lines 422 to 424 in 818d4dd
Therefore, we could create a
isWrapper()
method inside theStrictSessionHandler
class to check if the wrapped handler is an internal PHP session handler (\SessionHandler
), just likeAbstractProxy::isWrapper()
.That's the only solution I have in mind right now.