xoops forums

irmtfan

Module Developer
Posted on: 2012/8/13 10:38
irmtfan
irmtfan (Show more)
Module Developer
Posts: 3419
Since: 2003/12/7
#1

xoops_getConfigOption( 'language') is wrongly returned

Ok finally after many many investigation i found what is wrong in the xoops header when we change the language in Xlanguage and EMLH

The fact that both modules are failed to load local styles, take me to this point that it should be a bug in xoops 2.5.5
unfortunately we dont have any developer from RTL language countries.
Anyway, I finally found it is because the xoops_getConfigOption('language') function wrongly return the language.

xoops_getConfigOption('language') should be equal to $GLOBALS['xoopsConfig']['language']
but they are different.

so i did a temporary solution like this:
in include/functions.php around line 926:
change the xoops_getConfigOption function like this:
function xoops_getConfigOption($option$type 'XOOPS_CONF')
{
static 
$coreOptions = array();

if (
is_array($coreOptions) && array_key_exists($option$coreOptions)) {
return 
$coreOptions[$option];
}
// START hacked by irmtfan to solve language issue
if ( $option == 'language') {
return 
$GLOBALS['xoopsConfig'][$option];
}
// END hacked by irmtfan to solve language issue

$ret false;
$config_handler =& xoops_gethandler('config');
$configs $config_handler->getConfigsByCat((is_array($type)) ? $type constant($type));
if (
$configs) {
if (isset(
$configs[$option])) {
$ret $configs[$option];
}
}
$coreOptions[$option] = $ret;
return 
$ret;
}


If anybody have better code please contribute.
Now Xlanguage and EMLH can work perfectly. (local stylesheet will be changed based on languages)

bug in the xoops tracker with highest priority:
https://sourceforge.net/tracker/?func= ... roup_id=41586&atid=430840

zyspec

Module Developer
Posted on: 2012/8/13 16:28
zyspec
zyspec (Show more)
Module Developer
Posts: 1077
Since: 2004/9/21
#2

Re: xoops_getConfigOption('language') is wrongly returned

Sounds like a great find irmtfan! The fix might work under some circumstances but should be fixed properly in the core for the next release. Core developers need to figure out WHY they're different and fix the source of the problem. This could cause problems other places in the core, modules, etc. too if it's just 'patched' here.

There also appears to be a problem if 'type' is passed to this function as an array. The result is that this routine tries to pass the array on to the handler and then execute the 'getConfigsbyCat' method which doesn't know how to handle 'type' as an array. 'getConfigsbyCat' attempts to get the integer value of 'type' (the array), which won't give any meaningful results.

Fortunately this code has all been refactored in 2.6 but we need to get it patched in the 2.5.x series code until then.

MACTEP

Not too shy to talk
Posted on: 2012/8/13 19:45
MACTEP
MACTEP (Show more)
Not too shy to talk
Posts: 127
Since: 2009/4/4 5
#3

xoops_getConfigOption ('language') is wrongly returned

Because of the long header corrupted home page.


Resized Image

irmtfan

Module Developer
Posted on: 2012/8/14 6:32
irmtfan
irmtfan (Show more)
Module Developer
Posts: 3419
Since: 2003/12/7
#4

Re: xoops_getConfigOption ('language') is wrongly returned

zyspec:
thank you for your participation.
IMO this temporary solution is good enough for 2.5.5
Im sure that there is no other function that return the language in 2.5.5.
Also as you said xoops_header, xoops_getConfigOption and all $GLOBALS will be deprecated in 2.6
IMO it is a waste of time for core team to work more on 2.5.5
this is a functional bug not a security bug and just fixed by now.

zyspec

Module Developer
Posted on: 2012/8/14 12:51
zyspec
zyspec (Show more)
Module Developer
Posts: 1077
Since: 2004/9/21
#5

Re: xoops_getConfigOption( 'language') is wrongly returned

irmtfan,

You're right, the core team will need to decide if they want to fix this in the 2.5.x series. As a module developer I hope it's fixed in an upcoming maintenance release - before 2.6. It's not a major architectural change and Xoops 2.6 is 6-9 months away from production level. I'm sure there are others who won't see this in an engish forum thread that need this fixed.

There's an underlying issue that should be looked at to make sure it's not carried forward into the 2.6 series.

Mamba

Moderator
Posted on: 2012/8/14 13:08
Mamba
Mamba (Show more)
Moderator
Posts: 10944
Since: 2004/4/23
#6

Re: xoops_getConfigOption( 'language') is wrongly returned

Quote:
xoops_getConfigOption('language') should be equal to $GLOBALS['xoopsConfig']['language']
but they are different.

Can you show an example of how they are different?

What it should be, and what it is?

Thanks.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

irmtfan

Module Developer
Posted on: 2012/8/15 4:44
irmtfan
irmtfan (Show more)
Module Developer
Posts: 3419
Since: 2003/12/7
#7

Re: xoops_getConfigOption( 'language') is wrongly returned

Yes Mamba.
I illustrate the issue for non coders members.
http://www.jadoogaran.org/get_language_xoops255.php
You can download this script and test in any xoops 2.5.5:
http://www.jadoogaran.org/get_language_xoops255.php.zip

As I stated before it is just important for ML websites because single language websites like xoops.org dont need any other language option!!!