Skip to content

[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

Merged
merged 1 commit into from
Aug 18, 2014

Conversation

webmozart
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #11580
License MIT
Doc PR -

@stof
Copy link
Member

stof commented Aug 6, 2014

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

@webmozart
Copy link
Contributor Author

Yes, I just realized that too. What about transforming "auto" to "2.4"/"2.5-bc" already during configuration parsing?

@webmozart
Copy link
Contributor Author

I did both now.

@Tobion
Copy link
Contributor

Tobion commented Aug 6, 2014

👍

It's crazy what series of changes have been required to rewrite a part of the validation component in a BC way.

@webmozart
Copy link
Contributor Author

@Tobion Yes, indeed.

See #11587 for some more sanity. :)

@stof
Copy link
Member

stof commented Aug 6, 2014

@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

@stof
Copy link
Member

stof commented Aug 6, 2014

#11587 makes this PR obsolete, right ?

@webmozart
Copy link
Contributor Author

@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.

@stof
Copy link
Member

stof commented Aug 6, 2014

yeah, then OK (it will conflict though)

@webmozart
Copy link
Contributor Author

I fixed the implementation under PHP < 5.3.9 now. The previous code didn't work.

@webmozart
Copy link
Contributor Author

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; })
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, good point.

@webmozart
Copy link
Contributor Author

@stof Is the PR good to merge for you?

->beforeNormalization()
// XML parses as numbers, not as strings
Copy link
Member

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

@stof
Copy link
Member

stof commented Aug 11, 2014

@webmozart nope it is not. As said in my comment above, the current code of the PR is a BC break.

@webmozart webmozart added the Bug label Aug 12, 2014
@webmozart
Copy link
Contributor Author

@stof I fixed your comments now.

@webmozart
Copy link
Contributor Author

ping @symfony/deciders

@stof
Copy link
Member

stof commented Aug 18, 2014

👍

@webmozart webmozart merged commit a74b758 into symfony:2.5 Aug 18, 2014
webmozart added a commit that referenced this pull request Aug 18, 2014
…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
@webmozart webmozart deleted the issue11580 branch August 18, 2014 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants