-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] VoterInterface::vote(TokenInterface $token, $subject, array $attributes) #16600
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
Comments
@lyrixx this breaks BC for existing voters as they now need to support receiving a scalar or an array though. And there is no way to warn users about it (we don't know whether the internal implementation handles this case properly) |
@stof I disagree with you. This is not a BC break, because nothing change here. It's just PHP doc.
I do, cause I already use it. Everything works as expected. |
no it is not phpdoc. It is changing the contract. currently, it is OK for a voter to use Your argument saying that it is just phpdoc is wrong. It would also mean that changing the return value of any method is OK in PHP 5, as we always rely on the phpdoc to define our contracts. And this is clearly false.
everything works as expected in your voters. This does not mean that it does in all voters existing in all Symfony projects out there. And we actually even know the opposite, as we have a case in Symfony itself where it does not. |
What do you propose to fix this issue? |
well, the way to fix this would be to make the change only in 3.0, and document the BC break in the upgrade path. Then, warning about the fact that scalars and arrays are not handled by the implementation cannot be done by Symfony deprecation warnings, so we must rely on people reading the upgrade doc. But a static analyzer could detect the bug in the implementation. People wanting to write code compatible with both 2.8 and 3.0 should follow 2 rules:
|
I would rename the |
$resource is misleading IMHO and can be confused with a php resource. $subject looks just fine. |
Good point @nicolas-grekas! |
Hmm, I think we all miss something here.
So it's well an object, but not an object from OOP, but an object from natural language. as a reminder, The security component was a port of Spring Security Framework, and in Java almost everything is an Object (OOP). So IMHO, when Fab port the security component, he just made a typo ;) |
@nicolas-grekas Why did you close it? |
The interface is still wrong, isn't it? |
see #16754 |
I once failed with a PR on this topic (#13622) and I'd still love to see this change happen. 😃 |
Well, now that we have core code that allows to vote on other data too, imho it doesn't make sense to not update the interface accordingly. |
…(xabbuh) This PR was merged into the 2.8 branch. Discussion ---------- [Security] add subject variable to expression context | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #16600 | License | MIT | Doc PR | TODO Commits ------- 346943e add subject variable to expression context
…te() (xabbuh) This PR was merged into the 3.0-dev branch. Discussion ---------- [Security] allow arbitrary types in VoterInterface::vote() | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #16600 | License | MIT | Doc PR | TODO Commits ------- 9054bdf allow arbitrary types in VoterInterface::vote()
Currently, nothing prevent users to use scalar for the
$object
parameter inVoterInterface::vote(TokenInterface $token, $object, array $attributes)
.We already depreciated
VoterInterface::supportsAttribute
andVoterInterface::supportsClass
.So I propose this new interface:
The text was updated successfully, but these errors were encountered: