[FIX] Currency CRON Update uses first available Module
Posted: Tue Jan 12, 2010 12:56 am
This fix resolves a problem with the CRON Auto update functionality used in the Currencies setting.
Symptom/Problem:
The UpdateCurrenciesFromCron() function was using a very stupid assumption that the first currency exchange module was:
- working
- providing valid data
- enabled
It has absolutely no sanity checks and frankly if someone had a module that was providing poor exchange rates it would happily take those over your enabled module provided the duff mod' name was earlier in the alphabet. Stupid... Very, VERY stupid!
The fix:
Open: /lib/currency.php
Find:
Replace with:
Symptom/Problem:
The UpdateCurrenciesFromCron() function was using a very stupid assumption that the first currency exchange module was:
- working
- providing valid data
- enabled
It has absolutely no sanity checks and frankly if someone had a module that was providing poor exchange rates it would happily take those over your enabled module provided the duff mod' name was earlier in the alphabet. Stupid... Very, VERY stupid!
The fix:
Open: /lib/currency.php
Find:
Code: Select all
/**
* Just get the first available converter for the time being
*/
$converters = GetAvailableModules('currency');
$converter = $converters[$c_id]['object'];
Code: Select all
/**
* STOP: Just get the first available converter for the time being
*
* FIX: Stop making assumptions and check if the module is enabled
* before you use it.
*/
$converters = GetAvailableModules('currency');
foreach ($converters AS $c_id => $converter) {
if($converter['enabled']) {
break;
}
}
$converter = $converters[$c_id]['object'];