Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.8.0

Bug #2177 Not obtaining ECB rates or UN Currencies correctly
Submitted: 2004-08-20 14:04 UTC
From: mat at sharrow dot me dot uk Assigned: cross
Status: Closed Package: Services_ExchangeRates
PHP Version: 5.0.0 OS: Linux Mandrake 9
Roadmaps: (Not assigned)    
Subscription  


 [2004-08-20 14:04 UTC] mat at sharrow dot me dot uk
Description: ------------ When trying to convert money using the default European Central Bank driver in debug mode I get the error : Error: Invalid currency: GBP When looking at the error log there are a lot of errors. Reproduce code: --------------- $objExchange = new Services_ExchangeRates(); $objExchange->setToDebug(); $returnValue = $objExchange->convert('GBP','CYP', 100); Expected result: ---------------- To convert the monetry values and return it without an error message on screen when in debug mode, and there should be nothing in the error_log. Actual result: -------------- [20-Aug-2004 15:03:29] PHP Notice: Undefined variable: cacheLength in /usr/local/php5/lib/php/Services/ExchangeRates.php on line 214 [20-Aug-2004 15:03:29] PHP Notice: Undefined offset: 0 in /usr/local/php5/lib/php/Services/ExchangeRates/Rates_ECB.php on line 86 [20-Aug-2004 15:03:29] PHP Notice: Trying to get property of non-object in /usr/local/php5/lib/php/Services/ExchangeRates/Rates_ECB.php on line 86 [20-Aug-2004 15:03:29] PHP Notice: Undefined offset: 0 in /usr/local/php5/lib/php/Services/ExchangeRates/Rates_ECB.php on line 89 [20-Aug-2004 15:03:29] PHP Notice: Trying to get property of non-object in /usr/local/php5/lib/php/Services/ExchangeRates/Rates_ECB.php on line 89 [20-Aug-2004 15:03:29] PHP Warning: Invalid argument supplied for foreach() in /usr/local/php5/lib/php/Services/ExchangeRates/Rates_ECB.php on line 92 [20-Aug-2004 15:03:29] PHP Notice: Undefined variable: rates in /usr/local/php5/lib/php/Services/ExchangeRates.php on line 184 [20-Aug-2004 15:03:29] PHP Notice: Undefined variable: rates in /usr/local/php5/lib/php/Services/ExchangeRates.php on line 185 [20-Aug-2004 15:03:29] PHP Notice: Undefined variable: cacheLength in /usr/local/php5/lib/php/Services/ExchangeRates.php on line 214 [20-Aug-2004 15:03:29] PHP Warning: asort() expects parameter 1 to be array, null given in /usr/local/php5/lib/php/Services/ExchangeRates.php on line 237 [20-Aug-2004 15:03:29] PHP Warning: array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in /usr/local/php5/lib/php/Services/ExchangeRates.php on line 243 [20-Aug-2004 15:03:29] PHP Warning: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /usr/local/php5/lib/php/Services/ExchangeRates.php on line 243

Comments

 [2004-08-20 14:27 UTC] mat at sharrow dot me dot uk
have my previous comments been added?
 [2004-08-20 14:34 UTC] mat at sharrow dot me dot uk
There are two main problems, 1 with the ECB Rates driver and 1 with the UN Currency driver. The root cause of these two problems are either the XML feed has changed format, or the XML parser has changed the way in which node objects are created into a parse tree. I can not comment on either. There are also a number of smaller bugs indicated by warnings and notices in the error log. I have fixed all these problems and I am including diffs for the three files that I have changed, Exchange_Rates.php, Exchange_Rates/Currencies_UN.php and ExchangeRates/Rates_ECB.php. FILE :: Exchange_Rates.php -------------------------- 182c182 < $rateData = $this->retrieveData('Rates_' . $ratesSource, $this->_cacheLengthRates); --- > $rateData = $this->retrieveData('Rates_' . $ratesSource, $this->_cacheLengthRates); 184,185c184,185 < $this->ratesUpdated = $rateData['date']; < $this->ratesSource = $rateData['source']; --- > $this->ratesUpdated = $rates['date']; > $this->ratesSource = $rates['source']; 188,189c188 < < --- > 207c206 < function retrieveData($source, $cacheLength) { --- > function retrieveData($source, $cacheLenth) { 228,231c227 < function getValidCurrencies($currencies, $rates) { < < $validCurrencies = array(NULL); < --- > function getValidCurrencies($currencies, $rates) { FILE :: ExchangeRates/Rates_ECB.php ----------------------------------- 84c84 < --- > 86c86 < $return['date'] = $root->children[5]->children[1]->attributes['time']; --- > $return['date'] = $root->children[2]->children[0]->attributes['time']; 89c89 < $xrates = $root->children[5]->children[1]->children; --- > $xrates = $root->children[2]->children[0]->children; 93,95c93 < if ($rateinfo->name == 'Cube') { < $return['rates'][$rateinfo->attributes['currency']] = $rateinfo->attributes['rate']; < } --- > $return['rates'][$rateinfo->attributes['currency']] = $rateinfo->attributes['rate']; 97c95 < --- > FILE :: ExchangeRates/Currencies_UN.php --------------------------------------- 77c77 < --- > 82c82 < $currencies[$curr->children[1]->content] = $curr->children[3]->content; --- > $currencies[$curr->children[0]->content] = $curr->children[1]->content; 85c85 < --- >
 [2005-06-23 07:44 UTC] cross
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.