ZF-4963: Zend_Locale::isLocale evaluates int 0 to a locale
Description
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):
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);
}
}
Comments
Posted by Thomas Weidner (thomas) on 2008-11-18T14:02:43.000+0000
0, 1 and '' are no longer accepted as locale for validation.