ZF-8919: Zend_Validate_Float/Int does not work with setlocale


When Zend_Validate_Float and Zend_Validate_Int are used without giving the locale parameter, then PHP's internals are used.

In detail floatval and strval. floatval is not dependend on the locale. The problem is now that when a user uses the following code:

setlocale(LC_ALL, 'de_AT');
$valid = Zend_Validate_Float();
$valid->isValid('1,3'); // -> false

Any user would expect that the validator now uses PHP's/the environments locale settings and the string 1,3 returns true.

In fact 1,3 is converted by floatval to 1 as floatval seems to support ONLY english notation.

In past Zend_Validate_Float used Zend_Locale also for PHP internal detections. But I was said to revert it due to "performance"-reasons. So the question is now:

Should we document this PHP bug and note that Zend_Validate_Float supports only english noted strings (and not solve this php bug), or should we force to use the localized detection (with performance degration) when a non-english string is detected (or the detection fails on english strings when no locale parameter has been set)?

Note that this works:

$valid = Zend_Validate_Float('de_AT');
$valid->isValid('1,3'); // -> true

Please give me a note how I have to solve this problem so it conforms ZF policy.


Fixed with r21664