xoops forums

andrey3761

XOOPS Translator
Posted on: 2014/1/13 15:15
andrey3761
andrey3761 (Show more)
XOOPS Translator
Posts: 234
Since: 2008/8/21
#1

Bug in xoops_getModuleOption()

I found an error in the function xoops_getModuleOption().
The module MYMODULE1 configuration is IMGDIR.
The module MYMODULE2 configuration is IMGDIR.
The names of the modules are the same configurations.
If both call functions
$conf1 = xoops_getModuleOption( 'IMGDIR', 'MYMODULE1' );
$conf2 = xoops_getModuleOption( 'IMGDIR', 'MYMODULE2' );
then the last call will return the configuration of the first module
I corrected this error. The code below:
function xoops_getModuleOption($option$dirname '')
{
    static 
$modOptions = array();
    if (
is_array($modOptions) && isset($modOptions[$dirname][$option])) {
        return 
$modOptions[$dirname][$option];
    }

    
$ret false;
    
$module_handler =& xoops_gethandler('module');
    
$module =& $module_handler->getByDirname($dirname);
    
$config_handler =& xoops_gethandler('config');
    if (
is_object($module)) {
        
$moduleConfig =& $config_handler->getConfigsByCat(0$module->getVar('mid'));
        if (isset(
$moduleConfig[$option])) {
            
$ret $moduleConfig[$option];
        }
    }
    
$modOptions[$dirname][$option] = $ret;
    return 
$ret;
}

Mamba

Moderator
Posted on: 2014/1/13 16:12
Mamba
Mamba (Show more)
Moderator
Posts: 10337
Since: 2004/4/23
#2

Re: Bug in xoops_getModuleOption()

Thanks, Andrey. That's great!
Could you please submit it to SourceForge Bug Tracker, with the link to this thread?
Thanks!
Please support XOOPS & DONATE
Use 2.5.8 | Debug | Requests | Bugs

andrey3761

XOOPS Translator
Posted on: 2014/1/14 13:23
andrey3761
andrey3761 (Show more)
XOOPS Translator
Posts: 234
Since: 2008/8/21
#3

Re: Bug in xoops_getModuleOption()

Hi Mamba!
I submit an bug report.
https://sourceforge.net/p/xoops/bugs/1291/