Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.7.2
-
Fix Version/s: 1.8.0
-
Component/s: Zend_Translate
-
Labels:None
Description
Zend_Translate_Adapter::setOptions() uses foreach to loop over the options arrays. Assume the following options array:
$options = array(
'locale' => 'en',
'disable_notices' => true
);
On the first loop foreach executes setLocale() method which in turn may use disable_notices option to disable/enable throwing a notice. But disable_notices option is set on the second loop, therefore an 'old' value was used.
My proposal is to replace foreach with the following code:
$locale = false; foreach ($options as $key => $option) { if ($key == "locale") { $locale = $option; } else if ((isset($this->_options[$key]) and ($this->_options[$key] != $option)) or !isset($this->_options[$key])) { $this->_options[$key] = $option; $change = true; } } if($locale !== false) { $this->setLocale($locale); }
setOptions() is not a static method.
It is called at initiation and set when reading the translation file.
To disable notices afterwards in the mid of a script execution is really a no-go which leads to problems in normal cases.