Problem with FUDforum API global variables [message #161922] |
Sun, 21 February 2010 03:31 |
jlundan
Messages: 4 Registered: February 2010 Location: Finland
Karma: 0
|
Junior Member |
|
|
Hi,
I just started using the FUDApi and I ran to a small problem. It seems that FUDApi uses a bunch of global variables which are defined in GLOBALS.php and which should be included before using the FUDApi.
The GLOBALS.php expects to be run in global scope because it does not use either global keyword or $GLOBALS array while defining its variables. In other words, GLOBAL.php uses format:
$FUD_OPT_1 = 1737422013;
instead of for example
$GLOBALS['FUD_OPT_1'] = 1737422013;
The problem comes when I try to include the GLOBALS.php from inside a framework, such as CodeIgniter. In these cases my code is already inside a framework class or a method and I cannot go out of it. This means if I include the GLOBALS.php, the variables inside it are no longer global scoped but inside the scope of my framework class/method.
This causes FUDApi to crash with error message like "undefined index 'FUD_OPT_1'. The problem can be solved by modifying the GLOBALS.php to use $GLOBALS array.
|
|
|
|
Re: Problem with FUDforum API global variables [message #161927 is a reply to message #161926] |
Sun, 21 February 2010 08:45 |
jlundan
Messages: 4 Registered: February 2010 Location: Finland
Karma: 0
|
Junior Member |
|
|
Yes, but that's not quite what I am after. I'll try to reprhase:
My point is that as far as I understand: currently GLOBALS.php *must be* run in the global scope in order core.inc to work. (Sorry, I previously talked about FUDapi requiring it, but it seems that it is core.inc that crashes.)
Line 60 (in my installed version) of core.inc contains
if ($GLOBALS['FUD_OPT_3'] & 4194304) { // Plugins enabled
which tries to read global variable FUD_OPT_3. Because I use a PHP framework, I might not be able to include GLOBALS.php from global scope (like in my current project). This means that FUD_OPT_3 is no longer global variable and core.inc cannot find it. If variables in GLOBALS.php would be declared using the $GLOBALS variable like I suggested, I could include the GLOBALS.php from inside a PHP framework class as well.
I dont know if this is actually a bug or an enhancement, but I hope this clarifies my issue bit more.
|
|
|