Skip to content

[Security] Improve deprecation logic to minimalize the changes required in 3.0 #15886

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,9 @@ public function vote(TokenInterface $token, $object, array $attributes)
// as soon as at least one attribute is supported, default is to deny access
$vote = self::ACCESS_DENIED;

if ($isNewOverwritten) {
if ($this->voteOnAttribute($attribute, $object, $token)) {
// grant access as soon as at least one voter returns a positive response
return self::ACCESS_GRANTED;
}
} else {
if ($this->isGranted($attribute, $object, $token->getUser())) {
// grant access as soon as at least one voter returns a positive response
return self::ACCESS_GRANTED;
}
if ($this->voteOnAttribute($attribute, $object, $token)) {
// grant access as soon as at least one voter returns a positive response
return self::ACCESS_GRANTED;
}
}

Expand Down Expand Up @@ -146,6 +139,6 @@ protected function isGranted($attribute, $object, $user = null)
*/
protected function voteOnAttribute($attribute, $object, TokenInterface $token)
{
return false;
return $this->isGranted($attribute, $object, $token->getUser());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not move the trigger_error here as well? Then we don't need reflection at all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm classes that don't support any attributes would not trigger a warning then.

}
}