-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[HttpFoundation] Deprecate Request::getSession() when Request::hasSession() is false #9625
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
[HttpFoundation] Deprecate Request::getSession() when Request::hasSession() is false #9625
Conversation
security/form_login.rst
Outdated
@@ -444,7 +444,9 @@ remove this variable, it's better to use the | |||
// ... | |||
use Symfony\Component\Security\Http\Util\TargetPathTrait; | |||
|
|||
$targetPath = $this->getTargetPath($request->getSession(), $providerKey); | |||
$session = $request->hasSession() ? $request->getSession() : throw_no_session_exception(); |
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 am not convinced we should throw an exception here. Not having a session looks valid to me and we should then just use the empty value as the target path IMO.
components/http_foundation.rst
Outdated
@@ -235,6 +235,13 @@ the | |||
method tells you if the request contains a session which was started in one of | |||
the previous requests. | |||
|
|||
.. versionadded:: 4.1 | |||
|
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.
the blank line must be removed
components/http_foundation.rst
Outdated
Using :method:`Symfony\\Component\\HttpFoundation\\Request::getSession()` when no session | ||
has been set, was deprecated in Symfony 4.1. It will throw an exception in | ||
Symfony 5.0 when session is null. | ||
Use :method:`Symfony\\Component\\HttpFoundation\\Request::hasSession()` instead. |
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 would this reword to say something like "Check for an existing session first by calling Request::hasSession()
."
never mind, that part would have failed previously too if there is no session |
components/http_foundation.rst
Outdated
@@ -235,6 +235,12 @@ the | |||
method tells you if the request contains a session which was started in one of | |||
the previous requests. | |||
|
|||
.. versionadded:: 4.1 | |||
Using :method:`Symfony\\Component\\HttpFoundation\\Request::getSession()` | |||
when no session has been set, was deprecated in Symfony 4.1. It will throw |
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.
the comma could be removed
components/http_foundation.rst
Outdated
.. versionadded:: 4.1 | ||
Using :method:`Symfony\\Component\\HttpFoundation\\Request::getSession()` | ||
when no session has been set, was deprecated in Symfony 4.1. It will throw | ||
an exception in Symfony 5.0 when session is null. Check for an existing session |
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.
[...] when the session [...]
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.
and "null" should be enclosed by double backticks
A nice deprecation message! Thanks for contributing it. |
This fixes #9457.