PDA

View Full Version : Bug: Unitializied variables


Kirby
12-18-2007, 07:11 AM
You are using global variables for various stuff - for example $bbcode_parser, which causes a lot of problems.

Example:
member.php unsets $bbcode_parser when infractions are being shown.
If member.php is integrated and has at least one active module that requires the parser, this cause a PHP error.

Suggested Fix
Avoid global variables whenever possible.
If this is not possible prefix them.

As an interims fix, the loading stuff could be moved into print portal_output(), just before modules are actually executed.

Brian
12-18-2007, 04:34 PM
Could you elaborate a little on what you mean by prefixing the variables?

As for moving them into the print_portal_output() function, that's not really an option for those who have setting turned on to execute PHP modules within their own function.

Our Sponsors
 

Kirby
12-19-2007, 01:17 AM
Could you elaborate a little on what you mean by prefixing the variables?

$vba_bbcode_parser, $vba_foruminfo, ...


As for moving them into the print_portal_output() function, that's not really an option for those who have setting turned on to execute PHP modules within their own function.
As of 3.0 RC 2, modules are executed within a function (print_portal_output()) anyway. So moving the $vba_initload loading stuff there makes no difference - at least it does work for me and fixed the PHP error on $bbcode_parser :)

Side Note:
I suggest to change

$vba_initload = array(
'bbparser' => false,
'moderators' => false,
'forumperms' => false,
'ignusers' => false
);


to

$vba_initload = 0;




// Load BB code parser
if ($vba_mod['options'] & $vba_php_modint['load_bbcode_parser'])
{
$vba_initload['bbparser'] = true;
}

// Fetch forum permissions
if ($vba_mod['options'] & $vba_php_modint['load_forum_perms'])
{
$vba_initload['forumperms'] = true;
}

// Load moderators
if ($vba_mod['options'] & $vba_php_modint['load_moderators'])
{
$vba_initload['moderators'] = true;
}

// Load ignored users
if ($vba_mod['options'] & $vba_php_modint['load_ignusers'])
{
$vba_initload['ignusers'] = true;
}


to

$vba_initload |= $vba_mod['options'];



if ($pages['type'] == 'bb_code')
{
$vba_initload['bbparser'] = true;

to

if ($pages['type'] == 'bb_code')
{
$vba_initload |= $vba_php_modint['load_bbcode_parser'];



if ($vba_initload['bbparser'])
{

(and similar stuff)

to

if ($vba_initload & $vba_php_modint['load_bbcode_parser'])


=> less if checks, less code - but same result :)

Brian
12-22-2007, 03:09 PM
I kind of randomly thought about this the other night just as I was about to go to bed and though "oh, he just meant to use a different variable basically". Sometimes I never see the obvious and try to make things more complicated than they should be. Strangely enough I think it was just about the same time you posted your reply that I was thinking about that too. *cues twilight zone music* :p

Thanks for that and the other suggestions. I'll see if I can get them worked into the next release.

Our Sponsors
 

Kirby
06-26-2008, 03:10 AM
I am sorry but I have to bump this thread - I still get PHP Errors in current polls module with the parser if modules are executed within a function.

Brian
06-28-2008, 04:46 PM
You may need to disable the 'Process PHP Files Within a Function' in order to get it to work on those pages. That will most likely be disabled automatically in the next version for problem files like member.php and poll.php as well.