8000 remove deprecated code paths · linaori/symfony@2b6ce01 · GitHub
[go: up one dir, main page]

Skip t 8000 o content

Commit 2b6ce01

Browse files
committed
remove deprecated code paths
1 parent 906aad9 commit 2b6ce01

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

src/Symfony/Component/Security/CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ CHANGELOG
44
5.0.0
55
-----
66

7+
* Dropped support for passing more than one attribute to `AccessDecisionManager::decide()` and `AuthorizationChecker::isGranted()` (and indirectly the `is_granted()` Twig and ExpressionLanguage function):
8+
9+
**Before**
10+
```php
11+
if ($this->authorizationChecker->isGranted(['ROLE_USER', 'ROLE_ADMIN'])) {
12+
// ...
13+
}
14+
```
15+
16+
**After**
17+
```php
18+
if ($this->authorizationChecker->isGranted(new Expression("has_role('ROLE_USER') or has_role('ROLE_ADMIN')"))) {}
19+
// or:
20+
if ($this->authorizationChecker->isGranted('ROLE_USER')
21+
|| $this->authorizationChecker->isGranted('ROLE_ADMIN')
22+
) {}
23+
```
724
* Implementations of `Guard\AuthenticatorInterface::checkCredentials()` must return
825
a boolean value now. Please explicitly return `false` to indicate invalid credentials.
926
* The `LdapUserProvider` class has been removed, use `Symfony\Component\Ldap\Security\LdapUserProvider` instead.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1515
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
16+
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
1617

1718
/**
1819
* AccessDecisionManager is the base class for all access decision managers
@@ -58,7 +59,7 @@ public function __construct(iterable $voters = [], string $strategy = self::STRA
5859
public function decide(TokenInterface $token, array $attributes, $object = null)
5960
{
6061
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);
62+
throw new InvalidArgumentException(sprintf('Passing more than one Security attribute to %s() is not supported.', __METHOD__));
6263
}
6364

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

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
1515
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1616
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
17+
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
1718

1819
/**
1920
* AuthorizationChecker is the main authorization point of the Security component.
@@ -53,12 +54,10 @@ final public function isGranted($attributes, $subject = null): bool
5354
$this->tokenStorage->setToken($token = $this->authenticationManager->authenticate($token));
5455
}
5556

56-
if (!\is_array($attributes)) {
57-
$attributes = [$attributes];
58-
} 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);
57+
if (\is_array($attributes)) {
58+
throw new InvalidArgumentException(sprintf('Passing an array of Security attributes to %s() is not supported.', __METHOD__));
6059
}
6160

62-
return $this->accessDecisionManager->decide($token, $attributes, $subject);
61+
return $this->accessDecisionManager->decide($token, (array) $attributes, $subject);
6362
}
6463
}

0 commit comments

Comments
 (0)
0