Skip to content

Commit eceb0e5

Browse files
committed
tweak deprecation messages and changelog
1 parent 373469b commit eceb0e5

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

UPGRADE-5.0.md

+18
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,24 @@ Routing
413413
Security
414414
--------
415415

416+
* Dropped support for passing more than one attribute to `AccessDecisionManager::decide()` and `AuthorizationChecker::isGranted()` (and indirectly the `is_granted()` Twig and ExpressionLanguage function):
417+
418+
**Before**
419+
```php
420+
if ($this->authorizationChecker->isGranted(['ROLE_USER', 'ROLE_ADMIN'])) {
421+
// ...
422+
}
423+
```
424+
425+
**After**
426+
```php
427+
if ($this->authorizationChecker->isGranted(new Expression("has_role('ROLE_USER') or has_role('ROLE_ADMIN')"))) {}
428+
429+
// or:
430+
if ($this->authorizationChecker->isGranted('ROLE_USER')
431+
|| $this->authorizationChecker->isGranted('ROLE_ADMIN')
432+
) {}
433+
```
416434
* The `LdapUserProvider` class has been removed, use `Symfony\Component\Ldap\Security\LdapUserProvider` instead.
417435
* Implementations of `PasswordEncoderInterface` and `UserPasswordEncoderInterface` must have a new `needsRehash()` method
418436
* The `Role` and `SwitchUserRole` classes have been removed.

src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(iterable $voters = [], string $strategy = self::STRA
5858
public function decide(TokenInterface $token, array $attributes, $object = null)
5959
{
6060
if (\count($attributes) > 1) {
61-
@trigger_error('Passing more than one Security attribute to '.__METHOD__.' is deprecated since Symfony 4.4. Use multiple decide() calls or the expression language (e.g. "has_role(...) or has_role(...)") instead.', \E_USER_DEPRECATED);
61+
@trigger_error(sprintf('Passing more than one Security attribute to %s() is deprecated since Symfony 4.4. Use multiple decide() calls or the expression language (e.g. "has_role(...) or has_role(...)") instead.', __METHOD__), E_USER_DEPRECATED);
6262
}
6363

6464
return $this->{$this->strategy}($token, $attributes, $object);

src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ final public function isGranted($attributes, $subject = null): bool
5656
if (!\is_array($attributes)) {
5757
$attributes = [$attributes];
5858
} else {
59-
@trigger_error('Passing an array of Security attributes to '.__METHOD__.' is deprecated since Symfony 4.4. Use multiple isGranted() calls or the expression language (e.g. "has_role(...) or has_role(...)") instead.', \E_USER_DEPRECATED);
59+
@trigger_error(sprintf('Passing an array of Security attributes to %s() is deprecated since Symfony 4.4. Use multiple isGranted() calls or the expression language (e.g. "has_role(...) or has_role(...)") instead.', __METHOD__), E_USER_DEPRECATED);
6060
}
6161

6262
return $this->accessDecisionManager->decide($token, $attributes, $subject);

0 commit comments

Comments
 (0)