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] Deprecate use ofLocale validation constraint without setting "canonicalize" option totrue#26075
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
| publicfunction__construct($options =null) | ||
| { | ||
| if (!($options['canonicalize'] ??false)) { | ||
| @trigger_error('"canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Use "canonicalize"=>true instead.',E_USER_DEPRECATED); |
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 .... Set it totrue instead.
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.
I took as example the syntax atEmail::__construct(). Updated.
| { | ||
| if (!$constraintinstanceof Locale) { | ||
| thrownewUnexpectedTypeException($constraint,__NAMESPACE__.'\Locale'); | ||
| thrownewUnexpectedTypeException($constraint, Locale::class); |
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.
unrelated, should be reverted to ease merger's job
| * @dataProvider getInvalidLocales | ||
| */ | ||
| publicfunctiontestInvalidLocales($locale) | ||
| publicfunctiontestInvalidLocales(string$locale) |
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.
should be reverted to ease merger's job
3d1d2d2 tod465dbdComparephansys commentedFeb 11, 2018
Comments addressed. |
phansys commentedFeb 12, 2018
@fabpot,@nicolas-grekas; should we consider valid a locale including variants? "it_IT_NEDIS_ROJAZ_1901" by instance:http://php.net/manual/en/locale.getallvariants.php |
nicolas-grekas commentedFeb 12, 2018
Only if a real world app needs it. Let's not spend time on theoretical improvements. |
phansys commentedFeb 12, 2018
I can't imagine a practical use case using variants right now, but I think we should left a note about the situation in docs, explaining that locales including variants will not be considered valid. WDYT? |
phansys commentedFeb 16, 2018
Do you know how we could avoid having different results per platform? AppVeyor is reading "en-us.utf8@VARIANT" as a valid locale, while in Travis it is invalid. Shouldn't both environments be using the same bundled ICU data? |
nicolas-grekas commentedFeb 19, 2018
let's make the test case independent from the data version instead, we're not testing the data set here. |
| publicfunction__construct($options =null) | ||
| { | ||
| if (!($options['canonicalize'] ??false)) { | ||
| @trigger_error('The "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Set it to `true` instead.',E_USER_DEPRECATED); |
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.
we just merged a PR that removes all occurences of "and will be removed in 5.0."
would you mind removing them from this PR please?
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.
Sure! Done ;)
fabpot left a comment
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.
made some minor comments
| publicfunction__construct($options =null) | ||
| { | ||
| if (!($options['canonicalize'] ??false)) { | ||
| @trigger_error('The "canonicalize" option with value `false` is deprecated since Symfony 4.1. Set it to `true` instead.',E_USER_DEPRECATED); |
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.
Instead of backticks, you should use", and make one sentence;
The "canonicalize" option with value "false" is deprecated since Symfony 4.1, set it to "true" instead.
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.
Message updated. Thank you.
| publicfunctiontestNullIsValid() | ||
| /** | ||
| * @group legacy | ||
| * @expectedDeprecation The "canonicalize" option with value `false` is deprecated since Symfony 4.1. Set it to `true` instead. |
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.
Don't forget to change those expectations.
fabpot left a comment
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.
after the double-dots are removed
| publicfunction__construct($options =null) | ||
| { | ||
| if (!($options['canonicalize'] ??false)) { | ||
| @trigger_error('The "canonicalize" option with value "false" is deprecated since Symfony 4.1, set it to "true" instead..',E_USER_DEPRECATED); |
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.
double-dot :)
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.
Sorry. Fixed.
…nicalize" option to `true`
fabpot commentedFeb 20, 2018
Thank you@phansys. |
…raint without setting "canonicalize" option to `true` (phansys)This PR was merged into the 4.1-dev branch.Discussion----------[Validator] Deprecate use of `Locale` validation constraint without setting "canonicalize" option to `true`|Q |A ||--- |--- ||Branch |master ||Bug fix? |no ||New feature? |no ||BC breaks? |no ||Deprecations?|yes ||Tests pass? |yes ||Fixed tickets|#22353 ||License |MIT ||Doc PR |symfony/symfony-docs#9248|See#22353 (comment).Commits-------1572540 Deprecate use of `Locale` validation constraint without setting "canonicalize" option to `true`
…` validation constraint (phansys, javiereguiluz)This PR was merged into the master branch.Discussion----------[Validator] Add docs for "canonicalize" option at `Locale` validation constraintRelated tosymfony/symfony#22353,symfony/symfony#26075.Closes#7660.Commits-------14f10bc Final changes4c28e1f Minor changes0cc4ee8 Add docs for "canonicalize" option at `Locale` validation constraint
emodric commentedApr 4, 2018
Maybe I'm missing something, but how can setting https://github.com/symfony/symfony/blob/4.0/src/Symfony/Component/Validator/Constraints/Locale.php |
stof commentedApr 4, 2018
hmm, deprecating a value of the option at the same time it is added looks indeed weird, as it means we cannot write code running both on 4.0 and on 4.1 without deprecation |
phansys commentedApr 4, 2018
Because the deprecation is not about using the option itself, but about passing |
emodric commentedApr 4, 2018
@phansys But the option didn't exist before 4.1, therefore you couldn't even pass |
stof commentedApr 4, 2018
@emodric but omitting it is equivalent to passing |
phansys commentedApr 4, 2018
Right@emodric, this option will be introduced in 4.1, and the deprecation will be thrown if you omit it or if you pass |
emodric commentedApr 4, 2018
Okay, I understand, but:
How to solve this case that@stof mentions, or should we check for kernel version to avoid the deprecation? |
phansys commentedApr 4, 2018
Except a build matrix executing same build for both versions, I can't imagine which scenario could require avoid the deprecation without changing the codebase triggering it. But I think there is no way to use this validator without deprecation in |
emodric commentedApr 4, 2018
Build matrix discovered this deprecation for me, yes. No worries, I will add a Thanks for your help! |
Uh oh!
There was an error while loading.Please reload this page.
See#22353 (comment).