bug in currencydisplay.php or maybe in confg save functions

Started by razor7, December 26, 2011, 20:29:17 PM

Previous topic - Next topic

razor7

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!


MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

Milbo

Thanks but the solution is just to remove the adding of the php, becaus the list is including
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

razor7

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!
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

Milbo

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();
}
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

razor7

Fair enough

$module_filename = $converterFile; //This line must die!
$module_filename=substr($converterFile, 0, -4);
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

razor7

Hi, may this fix get merged into VM main branch as a fixed bug?

Thanks in advise!
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/