-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Fixed validator factory definition when the Validator API is "auto" for PHP < 5.3.9 #11584
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
Conversation
webmozart
commented
Aug 6, 2014
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #11580 |
License | MIT |
Doc PR | - |
I suggest we also add a parameter with the validation API being used, so that other bundles can know it and change their services in a compiler pass to support both the 2.4 and the 2.5 API at the same time. It will be necessary for #11582 in its current form |
Yes, I just realized that too. What about transforming "auto" to "2.4"/"2.5-bc" already during configuration parsing? |
I did both now. |
👍 It's crazy what series of changes have been required to rewrite a part of the validation component in a BC way. |
@Tobion the point is that the 2.5-BC API is BC. the 2.5 API is not BC. this is why we need to have to do lot of work, as we have to support constraint for 2 incompatible APIs |
#11587 makes this PR obsolete, right ? |
@stof Not necessarily. We still have different API versions, and I also think that resolving the "auto" value in the Configuration class is more elegant. Whether we add the "validator.api" parameter to the container is a good question, but I guess it's probably useful. |
yeah, then OK (it will conflict though) |
I fixed the implementation under PHP < 5.3.9 now. The previous code didn't work. |
Rebased and resolved conflicts. |
->ifTrue(function ($v) { return is_scalar($v); }) | ||
->then(function ($v) { return (string) $v; }) | ||
// XML parses as numbers, not as strings | ||
->always(function ($v) { return (string) $v; }) |
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.
you should still keep the is_scalar
check used previously. Otherwise, if someone puts an array in this config, he will get a warning because of the string casting before normalization instead of getting an exception because of invalid config
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.
Ok, good point.
@stof Is the PR good to merge for you? |
->beforeNormalization() | ||
// XML parses as numbers, not as strings |
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.
it is not only for XML. The following YAML will produce numbers as well:
framework:
validation:
api: 2.4
@webmozart nope it is not. As said in my comment above, the current code of the PR is a BC break. |
…or API is "auto" for PHP < 5.3.9
@stof I fixed your comments now. |
ping @symfony/deciders |
👍 |
…the Validator API is "auto" for PHP < 5.3.9 (webmozart) This PR was merged into the 2.5 branch. Discussion ---------- [FrameworkBundle] Fixed validator factory definition when the Validator API is "auto" for PHP < 5.3.9 | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #11580 | License | MIT | Doc PR | - Commits ------- a74b758 [FrameworkBundle] Fixed validator factory definition when the Validator API is "auto" for PHP < 5.3.9