Skip to content
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

Incompatibility with Numericality from v3.3.* to v3.4.2 #13843

Closed
mbrostami opened this issue Feb 19, 2019 · 4 comments
Closed

Incompatibility with Numericality from v3.3.* to v3.4.2 #13843

mbrostami opened this issue Feb 19, 2019 · 4 comments
Labels
bug A bug report status: low Low

Comments

@mbrostami
Copy link
Contributor

Expected and Actual Behavior

Validating string '123,123' by Numericality validator is true in Phalcon v3.3.2 but is false in v3.4.2.

Provide minimal script to reproduce the issue

$validator = new Numericality();
$validation = new Validation();
$validation->add('km', $validator);
var_dump($validation->validate(['km' => '123,123']));
die;

This is the line which is changed (!is_numeric(value) has been added in v3.4.x):
https://github.com/phalcon/cphalcon/blob/3.4.x/phalcon/validation/validator/numericality.zep#L74

@Jeckerson
Copy link
Member

#13450

In this issue problem is resolved with correcting setlocale(), which make sense. Because default behavior of is_numeric() is validate only float number with . and not with ,.

@joeyhub
Copy link
Contributor

joeyhub commented Mar 27, 2019

You should at all costs in PHP be avoiding anything to do with setlocale, that's for under the hood and a legacy horror that'll break a lot of things. You should never change it or rely on it. Instead use an appropriate library for intl. intl is the standard which should be used in place of the inbuilt PHP functions, however it's a bit bulky, when I last used it some message formats segfault and I'm not sure if it handles input as well as output.

PSR-joeyhub which supercedes all numeric PSRs and is the final PSR in the series almost entirely forbids the use of setlocale which must be locked to an appropriate system default (IE, C.utf8) as opposed to localised. Same as time, time must be UTC and instead DateTime used for converting to other timezones on input/output.

Take a look here:

https://www.php.net/manual/en/class.numberformatter.php

construct, format and parse are all good.

@mbrostami
Copy link
Contributor Author

mbrostami commented Mar 31, 2019

#13450

In this issue problem is resolved with correcting setlocale(), which make sense. Because default behavior of is_numeric() is validate only float number with . and not with ,.

Agree with that, but if Phalcon follows semantic versioning, then v3.4.x should not break v3.3.x functionality. I mean it could be fixed in v4.x.x.

@niden niden mentioned this issue May 17, 2019
4 tasks
@niden
Copy link
Member

niden commented May 17, 2019

Resolved in #14085

@niden niden closed this as completed May 17, 2019
@niden niden added the 4.0 label Jun 21, 2019
@niden niden added bug A bug report status: low Low and removed Bug - Low labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: low Low
Projects
None yet
Development

No branches or pull requests

4 participants