Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-13-2009, 07:59 PM
Will.Spencer's Avatar
Will.Spencer Will.Spencer is offline
 
Join Date: May 2006
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Enabling plugin causes whitescreen

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:
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: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:
Code:
$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?
Reply With Quote
  #2  
Old 03-13-2009, 08:23 PM
TigerC10's Avatar
TigerC10 TigerC10 is offline
 
Join Date: Apr 2006
Location: Austin, TX
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:

PHP Code:
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.
Reply With Quote
  #3  
Old 03-13-2009, 08:26 PM
Will.Spencer's Avatar
Will.Spencer Will.Spencer is offline
 
Join Date: May 2006
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

TigerC10:

Isn't that the opposite of what vBulletin.com recommends in the documentation and the forum?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!
Reply With Quote
  #4  
Old 03-13-2009, 08:49 PM
TigerC10's Avatar
TigerC10 TigerC10 is offline
 
Join Date: Apr 2006
Location: Austin, TX
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:27 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05180 seconds
  • Memory Usage 2,188KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete