ZF-4963: Zend_Locale::isLocale evaluates int 0 to a locale

Issue Type: Bug Created: 2008-11-17T08:41:21.000+0000 Last Updated: 2008-12-21T05:57:26.000+0000 Status: Resolved Fix version(s): - 1.7.1 (01/Dec/08)

Reporter: Mike Willbanks (mwillbanks) Assignee: Thomas Weidner (thomas) Tags: - Zend_Locale

Related issues: Attachments:


When the function isLocale is called from within the Translate view helper it will evaluate an integer 0 to a locale thus causing the vsprintf to fail when utilizing this to be sent for evaluation.

This broke BC between 1.6.2 and 1.7.

Reproduction: in a view script $this->translate('something %s', 0); which will now throw an exception because 0 became a locale due to the Zend_Locale::isLocale handling. This might be more of a bug in the Zend_View_Helper_Translate more than anything. Please see the view helper fix below.

Likely in the view helper itself, it should call strict since it is evaluating the result (patch):

<pre class="literal"> 
Index: libraries/Zend/View/Helper/Translate.php
--- libraries/Zend/View/Helper/Translate.php    (revision 12678)
+++ libraries/Zend/View/Helper/Translate.php    (working copy)
@@ -82,7 +82,7 @@
         $count  = count($options);
         $locale = null;
         if ($count > 0) {
-            if (Zend_Locale::isLocale($options[($count - 1)], null, false) !== false) {
+            if (Zend_Locale::isLocale($options[($count - 1)], true, false) !== false) {
                 $locale = array_pop($options);


Posted by Thomas Weidner (thomas) on 2008-11-18T14:02:43.000+0000

0, 1 and '' are no longer accepted as locale for validation.

Have you found an issue?

See the Overview section for more details.


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

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