VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: razor7 on December 26, 2011, 20:29:17 PM

Title: bug in currencydisplay.php or maybe in confg save functions
Post by: razor7 on December 26, 2011, 20:29:17 PM
Ja!, i think I found a bug in VM2 in file .../helpers/currencydisplay.php lines 44-53

In my case, $converterFile got this value from config "converter.php", so, line 44 allways fails, because gets this path ".../currency_converter/converter.php.php"

if (file_exists( JPATH_VM_ADMINISTRATOR.DS.'plugins'.DS.'currency_converter'.DS.$converterFile.'.php' )) {

$module_filename = $converterFile;

require_once(JPATH_VM_ADMINISTRATOR.DS.'plugins'.DS.'currency_converter'.DS.$converterFile.'.php');

if( class_exists( $module_filename )) {

$this->_currencyConverter = new $module_filename();

}

} else {

if(!class_exists('convertECB')) require(JPATH_VM_ADMINISTRATOR.DS.'plugins'.DS.'currency_converter'.DS.'convertECB.php');

$this->_currencyConverter = new convertECB();

}


Two options, trim the ".php", after getting "$converterFile  = VmConfig::get('currency_converter_module');" on line 41, or fix something in config save functions to trim the ".php" part of the filename

Adding this line after lien 41 makes sense!
        $converterFile=substr($converterFile, 0, strlen($converterFile)-4);

Be advised!


Title: Re: bug in currencydisplay.php or maybe in confg save functions
Post by: Milbo on December 27, 2011, 15:26:49 PM
Thanks but the solution is just to remove the adding of the php, becaus the list is including
Title: Re: bug in currencydisplay.php or maybe in confg save functions
Post by: razor7 on December 27, 2011, 16:21:37 PM
Hi, i don't think so, because line 47 will allways fail
if( class_exists( $module_filename )) {

It will never find a class named "converter.php"

The ".php" part of configuration MUST be trimmed at config save time, or at currency class load time!
Title: Re: bug in currencydisplay.php or maybe in confg save functions
Post by: Milbo on December 28, 2011, 00:20:27 AM
hmm or that?

if (file_exists( JPATH_VM_ADMINISTRATOR.DS.'plugins'.DS.'currency_converter'.DS.$converterFile )) {
$module_filename = $converterFile;
$module_filename=substr($converterFile, 0, -4);
require_once(JPATH_VM_ADMINISTRATOR.DS.'plugins'.DS.'currency_converter'.DS.$converterFile);
if( class_exists( $module_filename )) {
$this->_currencyConverter = new $module_filename();
}
} else {
if(!class_exists('convertECB')) require(JPATH_VM_ADMINISTRATOR.DS.'plugins'.DS.'currency_converter'.DS.'convertECB.php');
$this->_currencyConverter = new convertECB();
}
Title: Re: bug in currencydisplay.php or maybe in confg save functions
Post by: razor7 on December 28, 2011, 16:05:20 PM
Fair enough

$module_filename = $converterFile; //This line must die!
$module_filename=substr($converterFile, 0, -4);
Title: Re: bug in currencydisplay.php or maybe in confg save functions
Post by: razor7 on January 02, 2012, 16:18:45 PM
Hi, may this fix get merged into VM main branch as a fixed bug?

Thanks in advise!
Title: Re: bug in currencydisplay.php or maybe in confg save functions
Post by: Milbo on January 02, 2012, 18:48:43 PM
It is already since days in the svn. Read here http://dev.virtuemart.net/projects/virtuemart/wiki/Setting_up_a_Development_Environment