Skip to content

Commit c32d97d

Browse files
committed
minor #16379 [Security] Add deprecation information for is_anonymous (malteschlueter)
This PR was merged into the 5.4 branch. Discussion ---------- [Security] Add deprecation information for is_anonymous Don't know in which issue or pr this happend but I found in the UPGRADE-5.4.md that the `is_anonymous()` function is deprecated. Instead the `is_authenticated()` function should be used. https://github.com/symfony/symfony/blob/5.4/UPGRADE-5.4.md#security > Deprecate AuthenticationTrustResolverInterface::isAnonymous() and the is_anonymous() expression function as anonymous no longer exists in version 6, use the isFullFledged() or the new isAuthenticated() instead if you want to check if the request is (fully) authenticated How do we handle the upmerge? The deprecation information must be removed in 6.0 and the general information about the function in line 67-70. Should I create a follow up PR? Commits ------- 12fcb6a [Security] Add deprecation information for is_anonymous
2 parents 617ac31 + 12fcb6a commit c32d97d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

security/expressions.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ accepts an :class:`Symfony\\Component\\ExpressionLanguage\\Expression` object::
2424
public function index(): Response
2525
{
2626
$this->denyAccessUnlessGranted(new Expression(
27-
'"ROLE_ADMIN" in role_names or (not is_anonymous() and user.isSuperAdmin())'
27+
'"ROLE_ADMIN" in role_names or (is_authenticated() and user.isSuperAdmin())'
2828
));
2929

3030
// ...
@@ -78,6 +78,11 @@ Additionally, you have access to a number of functions inside the expression:
7878
equivalent to using the :ref:`isGranted() method <security-isgranted>`
7979
from the security service.
8080

81+
.. deprecated:: 5.4
82+
83+
The ``is_anonymous()`` function is
84+
deprecated since Symfony 5.4.
85+
8186
.. sidebar:: ``is_remember_me()`` is different than checking ``IS_AUTHENTICATED_REMEMBERED``
8287

8388
The ``is_remember_me()`` and ``is_fully_authenticated()`` functions are *similar*

0 commit comments

Comments
 (0)