Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Validator] Made sure that context changes don't leak out of (Contextual)ValidatorInterface#11412
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
webmozart commentedJul 17, 2014
| Q | A |
|---|---|
| Bug fix? | yes |
| New feature? | no |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #11046 |
| License | MIT |
| Doc PR | - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The Interface needs to be changed as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What about the$propertyPath variable that doesn't have a default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@webmozart Then you would need to check$this->context instanceof ExecutionContext in RecursiveContextualValidator whenever you call setNode. This is pretty ugly. So I think changing the interface is cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
And what will you pass to a different implementation when metadata is null? You would need to create a metadata instance, to be able to pass the other parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@Tobion After thinking about this some more, I figured that you are right. Passingnull to the method of an interface that technically does not acceptnull values is bogus, and introduces a dependency to the implementation. I changed the interface now.
redstar504 commentedJul 17, 2014
Hey guys, if you see my issue#11413 I was thinking that I could use this ExecutionContextInterface::setNode method in order to set the correct property_path for my constraint, but I didn't know what to specify for the $metadata argument. If this PR gets merged, would this be a valid workaround? |
webmozart commentedJul 18, 2014
@redstar504 See my answer to your ticket. Using |
tompedals commentedJul 18, 2014
We're still having issues if we use the 2.4 validation API. Errors are being set on the form rather than fields. Works fine with 2.5-bc and 2.5. |
webmozart commentedJul 18, 2014
@tompedals Could you provide a fork of symfony-standard which reproduces your issue? |
tompedals commentedJul 18, 2014
@webmozart I'll give it a try. It may well have just been cached. The main issue I was having is now resolved anyway as we can use the 2.5 API rather than 2.4. Thanks for looking into it. |
…ual)ValidatorInterface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
please update the phpdoc@param MetadataInterface|null
Tobion commentedJul 24, 2014
Btw, there is another Interface problem. |
Tobion commentedJul 24, 2014
And |
fabpot commentedJul 25, 2014
This one is quite critical as without the fix, people cannot upgrade from 2.4 to 2.5 (2.4 being obsolete now.) @webmozart@Tobion Can you find time to finish this one so that we can merge it soon? |
Tobion commentedJul 25, 2014
Looks good 👍 except the phpdoc I mentioned above. The other problems I figured out are unrelated and can be separate tickets. |
webmozart commentedJul 26, 2014
@Tobion Thanks, I addressed your comments now. If I get another go, I can merge the PR. /cc@stof |
… to ExecutionContextInterface
Tobion commentedJul 26, 2014
But startContext is a public method. So nothing hinders developers to actually use the parameter. So it's not only cosmetic. And changing the behavior of the parameter at some point could be considered BC break even though it's only intended for internal purposes. |
webmozart commentedJul 26, 2014
Sure, developers can use the parameter, but then their code is bound to the implementation, not the interface - which is their choice. If we want to change anything about that parameter, we need to do so in a BC fashion, but I don't think this is very likely. |
Tobion commentedJul 26, 2014
I dislike this because it does not respect the interface and is only possible in loosly checked languages like PHP. In stricter languages like Java this is not possible. To me this is a hack without any usefulness. And static code analysis will probably not like this either. I'm +0 |
webmozart commentedJul 26, 2014
I think the solution is pragmatic. But if others agree with you, I'm not opposed to adding another private method either. |
Tobion commentedJul 26, 2014
Another reason against it is that the parameter is not documented. And documentation is not only for users but also for understanding code, i.e. contributors. |
webmozart commentedJul 26, 2014
Feel free to open a PR to the branch. :) |
fabpot commentedJul 28, 2014
👍 |
…of (Contextual)ValidatorInterface (webmozart)This PR was merged into the 2.5 branch.Discussion----------[Validator] Made sure that context changes don't leak out of (Contextual)ValidatorInterface| Q | A| ------------- | ---| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#11046| License | MIT| Doc PR | -Commits-------ff48939 [Validator] Added markObjectAsInitialized() and isObjectInitialized() to ExecutionContextInterface14b60c8 [Validator] Fixed doc block91bf277 [Validator] Made sure that context changes don't leak out of (Contextual)ValidatorInterface
peterrehm commentedJul 28, 2014
I still see errors attached to a wrong filed with dev-master #7af2563 that errors are attached to the wrong field with 2.5 and 2.5-bc api. 2.4 api works fine. @webmozart Are you aware of further issues regarding this or shall I try to reproduce it in a SE? |
xabbuh commentedJul 28, 2014
@peterrehm 2.5 hasn't been merged into master since then. |
peterrehm commentedJul 28, 2014
@xabbuh Good catch, my bad. Just checked it against 2.5.x-master and could not reproduce my test cases. Seems to be fixed. Thanks! |
fabpot commentedJul 28, 2014
@peterrehm I've just merged 2.5 into master. |
peterrehm commentedJul 28, 2014
@fabpot Thanks. |