Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 0.8.0
-
Fix Version/s: 1.0.3
-
Component/s: Zend_Locale
-
Labels:None
Description
Problems arise when PHP converts integers and floats to strings using decimal place characters other than a period ('.'), which is the only decimal place separater supported by BCMath functions and the Zend_Locale_Math "proxy" class.
To reproduce the errors below on the ZF Community Development Server:
1. Copy TestConfiguration.php.dist to TestConfiguration.php
2. Comment the first line below in TestConfiguration.php, and comment out the second line below:
//define('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE', 'fr_FR@euro'); define('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE', false);
3. cd tests/Zend/Locale
4. php AllTests.php
zfdev Locale 737$ pwd
/home/gavin/www/zftrunk/tests/Zend/Localezfdev Locale 738$ uname -a
Linux www.zfdev.com 2.6.9-42.EL #1 Wed Jul 12 23:16:43 EDT 2006 i686 i686 i386 GNU/Linuxzfdev Locale 739$ php -v
PHP 5.1.6 (cgi-fcgi) (built: Oct 24 2006 19:38:28)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologieszfdev Locale 740$ svn update
At revision 3991.$ php AllTests.php
X-Powered-By: PHP/5.1.6
Content-type: text/htmlPHPUnit 3.0.0 by Sebastian Bergmann.
.......F..F..F......F..FF
Time: 00:06
There were 6 failures:
1) testToNumber(Zend_Locale_FormatTest)
string 0,1234567 expected
Failed asserting that <string:0,1234567> is equal to <string:0,0000000>.
/var/www/html/zftrunk/tests/Zend/Locale/FormatTest.php:97
/var/www/html/zftrunk/tests/Zend/Locale/AllTests.php:46
/var/www/html/zftrunk/tests/Zend/Locale/AllTests.php:622) testToFloat(Zend_Locale_FormatTest)
string 0,1234567 expected
Failed asserting that <string:0,1234567> is equal to <string:0,0000000>.
/var/www/html/zftrunk/tests/Zend/Locale/FormatTest.php:177
/var/www/html/zftrunk/tests/Zend/Locale/AllTests.php:46
/var/www/html/zftrunk/tests/Zend/Locale/AllTests.php:623) testtoInteger(Zend_Locale_FormatTest)
value 1234567- expected
Failed asserting that <string:1234567-> is equal to <string:1234567>.
/var/www/html/zftrunk/tests/Zend/Locale/FormatTest.php:253
/var/www/html/zftrunk/tests/Zend/Locale/AllTests.php:46
/var/www/html/zftrunk/tests/Zend/Locale/AllTests.php:624) testToNumberFormat(Zend_Locale_FormatTest)
string 0,1234567 expected
Failed asserting that <string:0,1234567> is equal to <string:0,0000000>.
/var/www/html/zftrunk/tests/Zend/Locale/FormatTest.php:657
/var/www/html/zftrunk/tests/Zend/Locale/AllTests.php:46
/var/www/html/zftrunk/tests/Zend/Locale/AllTests.php:625) testToFloatSetlocale(Zend_Locale_FormatTest)
Failed asserting that <string:1Â 234,50> is equal to <string:0,00>.
/var/www/html/zftrunk/tests/Zend/Locale/FormatTest.php:758
/var/www/html/zftrunk/tests/Zend/Locale/AllTests.php:46
/var/www/html/zftrunk/tests/Zend/Locale/AllTests.php:626) testRound(Zend_Locale_MathTest)
Failed asserting that <string:513695,4> is equal to <string:513695.4>.
/var/www/html/zftrunk/tests/Zend/Locale/MathTest.php:5020
/var/www/html/zftrunk/tests/Zend/Locale/AllTests.php:46
/var/www/html/zftrunk/tests/Zend/Locale/AllTests.php:62FAILURES!
Tests: 25, Failures: 6.
Attachments
Issue Links
| This issue is dependecy of: | ||||
| ZF-1049 | Problem with Zend_Locale_Format and setlocale() |
|
|
|
So the original problem is that php's BCMath implementation is not setLocale aware...
PHP converts the strings as demanded in setLocale and BCMath can only work with english locale.