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

Fixing formatting issues with description

verified your patch and implemented it (r23732) Thanks

Shouldn't this issue be closed as resolved?