Zend Framework

Wrong test for exists locale

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.10.6
  • Component/s: Zend_Locale
  • Labels:
    None

Description

Hi,
i have problem with commit #22278. After this commit is generated WARNING:

Warning</b>: array_key_exists() [<a href='function.array-key-exists'>function.array-key-exists</a>]: The first argument should be either a string or an integer in <b>/home/lestr/projekty/alarm-online/trunk/library/Zend/Locale.php</b> on line <b>811</b>

I think there is missing negation before calling is_array function.

This is svn diff from my local copy of releace branche

 
--- library/Zend/Locale.php     (revision 329)
+++ library/Zend/Locale.php     (working copy)
@@ -808,7 +808,7 @@
     public static function isLocale($locale, $strict = false, $compatible = true)
     {
         if (($locale instanceof Zend_Locale) 
-            || (is_array($locale) && array_key_exists($locale, self::$_localeData))
+            || (!is_array($locale) && array_key_exists($locale, self::$_localeData))
         ) {
             return true;
         }

Is this fix correct?

Activity

Hide
Mickael Perraud added a comment -

I don't know if it's the correct fix but I can confirm that there is a bug.

I think that should be:

public static function isLocale($locale, $strict = false, $compatible = true)
     {
         if (($locale instanceof Zend_Locale) 
-            || (is_array($locale) && array_key_exists($locale, self::$_localeData))
+            || (is_string($locale) && array_key_exists($locale, self::$_localeData))
         ) {
             return true;
         }
Show
Mickael Perraud added a comment - I don't know if it's the correct fix but I can confirm that there is a bug. I think that should be:
public static function isLocale($locale, $strict = false, $compatible = true)
     {
         if (($locale instanceof Zend_Locale) 
-            || (is_array($locale) && array_key_exists($locale, self::$_localeData))
+            || (is_string($locale) && array_key_exists($locale, self::$_localeData))
         ) {
             return true;
         }
Hide
Thomas Weidner added a comment -

Fixed by r22314

Show
Thomas Weidner added a comment - Fixed by r22314

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: