PDA

View Full Version : Enabling plugin causes whitescreen


Will.Spencer
03-13-2009, 07:59 PM
I have a small PHP program, http://www.netbuilders.org/showlinks.php, which acts as a link rotator.

I want to include it in my vBulletin templates, so I created a plugin called showlinks.

I used global_start as the hook location and used this as my plugin PHP code:
ob_start();
include('/usr/local/www/data/netbuilders.org/showlinks.php');
$nblinks = ob_get_contents();
ob_end_clean();

When I enable the plugin, the forum stops working. It will only display a blank white screen until I disable the plugin again. :(

I have read these two documents and they are not providing me with any usable clues:

http://www.vbulletin.com/docs/html/templates_externalfiles
http://www.vbulletin.com/forum/showthread.php?p=1066718
Has anyone seen vBulletin do this before?

When the whitescreen behavior is occurring, this error message fills my Apache logs: "PHP Fatal error: Call to a member function query_read_slave() on a non-object in /usr/local/www/data/netbuilders.org/includes/functions.php on line 4819."

The code around line 4819 is:

$ismod_all = $vbulletin->db->query_read_slave("
SELECT forumid, moderatorid, permissions, permissions2
FROM " . TABLE_PREFIX . "moderator
WHERE userid = $userid" . (!$issupermod ? ' AND forumid != -1' : '')
);


Any ideas?

TigerC10
03-13-2009, 08:23 PM
The error you're talking about means that you haven't created the $db object in $vbulletin. Because you have the member function defined, and you don't have the $db object, it means that global.php is terminating early (probably through an error).

The global_start hook that you chose is why it's terminating early.


I believe that because you're fussing with ob_ stuff it's not having the desired result. Change your plugin code to be this:


include('/usr/local/www/data/netbuilders.org/showlinks.php');


Then change your showlinks.php file to define the $nblinks variable as whatever you want it to appear as in your templates.

Will.Spencer
03-13-2009, 08:26 PM
TigerC10:

Isn't that the opposite of what vBulletin.com recommends in the documentation and the forum?
http://www.vbulletin.com/docs/html/templates_externalfiles
http://www.vbulletin.com/forum/showthread.php?p=1066718
Ah... wait... your post contains the answer! showlinks.php uses $db as a variable and that's causing a conflict.

Changed, tested, confirmed, fixed.

Thanks man! :)

TigerC10
03-13-2009, 08:49 PM
Eh, it's a matter of style preference. I prefer to avoid the ob_ stuff because the PHP api changes how that stuff is handled from time to time.

Glad I could help you trace your error, though. :)