andrey3761 andrey3761
  • XOOPS Translator
  • XOOPS Translator
  • Joined: 2008/8/21 12:28
  • From Transnistrian
  • Group: Registered Users
  • Posts: 234
  • Posted on: 2014/1/13 15:15
Bug in xoops_getModuleOption() #1
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 Mamba
  • Moderator
  • Moderator
  • Joined: 2004/4/23 14:58
  • From Ohio, USA
  • Group: Webmaster Registered Users Designer Group Super Moderator
  • Posts: 10293
  • Posted on: 2014/1/13 16:12
Re: Bug in xoops_getModuleOption() #2
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 andrey3761
  • XOOPS Translator
  • XOOPS Translator
  • Joined: 2008/8/21 12:28
  • From Transnistrian
  • Group: Registered Users
  • Posts: 234
  • Posted on: 2014/1/14 13:23
Re: Bug in xoops_getModuleOption() #3
Hi Mamba!
I submit an bug report.
https://sourceforge.net/p/xoops/bugs/1291/
How to effectively post a question in the Xoops forums? - Read here...
Design by: XOOPS UI/UX Team