Issues

ZF-9181: Wrong condition in Zend_Currency constructor makes the whole component unusable

Description

In our project, we're using Zend_Currency to handle prices, but so far, we've been unable to make it work. Even the simplest example from the documentation throws an error:

This one works: {quote} new Zend_Currency( array('value' => 100) ); {quote}

This one fails: {quote} new Zend_Currency( array('value' => 100.50) ); {quote}

Type: Zend_Cache_Exception Message: Invalid id or tag 'Zend_LocaleC_fr_FR_currencytoname_100.5' : must use only [a-zA-Z0-9_]

As soon as we're using anything else than an integer, it fails. Zend_Currency tries to cache something under a wrong cache identifier because of a single malformed condition in the Zend_Currency constructor:

The line 103: if (!isset($options['currency']) || !is_array($options)) {

Should read: if (!isset($this->_options['currency']) || !is_array($options)) {

In Zend_Currency::setLocale() just above (line 101), the 'currency' option is set by default if missing, this makes the whole following condition pass although it should not. Moreover, this does not seem correct that Zend_Currency puts the value of the currency (100.50) in the 'currency' option, there could be another problem somewhere.

Comments

Fixed with r21059