ZF-11072: Zend_Locale::getTranslation not handling results of '0' properly
Description
Currently if the result of a call to getTranslation should return a '0' it actually returns false due to an internal usage of the empty() function in PHP. A return of 'false' is NOT the same as '0' and should not be treated the same as it breaks functionality. This problem has existed for at least 2 years now, perhaps longer.
Here is a test case for the Zend_Locale unit test to illustrate the problem.
public function testCurrencyFraction() {
$this->assertFalse(Zend_Locale::getTranslation('USD', 'CurrencyFraction'));
$this->assertEquals('0', Zend_Locale::getTranslation('JPY', 'CurrencyFraction'));
$this->assertEquals('2', Zend_Locale::getTranslation('CHF', 'CurrencyFraction'));
$this->assertEquals('3', Zend_Locale::getTranslation('BHD', 'CurrencyFraction'));
$this->assertEquals('2', Zend_Locale::getTranslation('DEFAULT', 'CurrencyFraction'));
}
My fix is included here, but not 100% sure it's bug free.
-- a/Zend/Locale.php
+++ b/Zend/Locale.php
@@ -666,7 +666,7 @@ class Zend_Locale
require_once 'Zend/Locale/Data.php';
$locale = self::findLocale($locale);
$result = Zend_Locale_Data::getContent($locale, $path, $value);
- if (empty($result) === true) {
+ if (empty($result) === true && $result !== '0') {
return false;
}
Comments
Posted by Lee Saferite (lsaferite) on 2011-02-14T03:23:23.000+0000
Fixing formatting issues with description
Posted by Michelangelo van Dam (dragonbe) on 2011-02-19T10:53:21.000+0000
verified your patch and implemented it (r23732) Thanks
Posted by Lee Saferite (lsaferite) on 2012-05-17T16:04:13.000+0000
Shouldn't this issue be closed as resolved?