Issues

ZF-9889: Wrong test for exists locale

Issue Type: Bug Created: 2010-05-26T02:00:33.000+0000 Last Updated: 2010-05-27T14:27:50.000+0000 Status: Resolved Fix version(s): - 1.10.6 (22/Jun/10)

Reporter: Lukas Drbal (lestr) Assignee: Thomas Weidner (thomas) Tags: - Zend_Locale

Related issues: Attachments:

Description

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

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

I think there is missing negation before calling is_array function.

This is svn diff from my local copy of releace branche

<pre class="literal"> 
--- 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?

Comments

Posted by Mickael Perraud (mikaelkael) on 2010-05-27T02:00:42.000+0000

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

I think that should be:

<pre class="highlight">
     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;
         }

Posted by Thomas Weidner (thomas) on 2010-05-27T14:27:46.000+0000

Fixed by r22314

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts