Zend Framework

Wrong condition in Zend_Currency constructor makes the whole component unusable

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 1.10.1
  • Fix Version/s: 1.10.2
  • Component/s: Zend_Currency
  • Labels:
    None

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:

new Zend_Currency(
array('value' => 100)
);

This one fails:

new Zend_Currency(
array('value' => 100.50)
);

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.

Activity

Hide
Thomas Weidner added a comment -

Fixed with r21059

Show
Thomas Weidner added a comment - Fixed with r21059

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: