Issues

ZF-7864: Zend_Currency::toCurrency() ignores option param "currency"

Issue Type: Bug Created: 2009-09-17T02:47:24.000+0000 Last Updated: 2009-09-28T11:02:19.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Dennis Becker (radhad) Assignee: Thomas Weidner (thomas) Tags: - Zend_Currency

Related issues: Attachments: - CurrencyTest.php.patch

Description

I always use an instance of Zend_Currency to display prices etc. Now I ran into a bug after upgrading from 1.7.8 to 1.9.2 - the toCurrency method ignores the currency value in the option array. Here is a small test I used:

<pre class="highlight">
$value = '';
$currencyObject = new Zend_Currency('de_DE');
$value = $currencyObject->toCurrency(2.3, array('currency' => 'USD', 'precision' => 4));
Zend_Debug::dump($value); // prints "2,3000 €" - expected "2,3000 $"

$value = '';
$currencyObject = new Zend_Currency('USD', 'de_DE');
$value = $currencyObject->toCurrency(2.3, array('precision' => 4));
Zend_Debug::dump($value); // prints "2,3000 $" as expected

The first example is often used, because I cannot know which currency should be used for the customer - so setting the currency while converting is a must have for me. If I see it right, the bug depends on getSymbol() which results in an error if no locale is given. I will add a patch which corrects the problem for me.

Comments

Posted by Dennis Becker (radhad) on 2009-09-18T02:19:13.000+0000

I will add additionally a Unit-Test patch ( I read the "Bughunt day" notification today) so that it does not need to be double-researched. This will take some minutes I think ;) Just wait until I have uploaded it.

Posted by Dennis Becker (radhad) on 2009-09-22T06:27:17.000+0000

Added UnitTest to CurrencyTest.php

Posted by Thomas Weidner (thomas) on 2009-09-28T10:56:51.000+0000

Note that this "patch" introduces a new problem and can not be used as is.

Posted by Thomas Weidner (thomas) on 2009-09-28T11:02:18.000+0000

Note that your provided example set's another display type at initiation than at output. This leads to the behaviour that the output uses another display that the one you set. If you would set the wished display type then the code would work. This has not changed since ZF 1.7.8.

Fixed with a new feature to automatically detect the wished display type. (r18432)

Have you found an issue?

See the Overview section for more details.

Copyright

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

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

Contacts