Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 24 Oct 2012, 17:33
DetroitYES's Avatar
DetroitYES DetroitYES is offline
 
Join Date: Mar 2009
$vbulletin->options not available at global_bootstrap_complete unless via include?!

So I've noticed this hiccup while developing a few products and thought I'd get some clarification on it here. Basically, if I write a plugin for my atdisg product with this code at global_bootstrap_complete, it won't pick up the option's value so nothing will be echoed:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Certainly annoying, but perhaps the options are declared after the hook is fired. Fair enough, except that does not seem to be the case. What perplexes me is if I write a php file in the includes directory called atdisg_includes.php, with a function that will return the $vbulletin->options... :


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

...and then include this file, and call the function at the same (global_bootstrap_complete) location I am able to use the values?!


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The reason I ask is that I'd like to redefine this option outside of the product (special case for one board) but because I cannot access it before it it utilized, I can't redefine it... I *could* make a setter function and include that I suppose but I'd like to have a better picture of why this is occuring before I do. It just really perplexes me that the options are in scope for the include file but not for the plugin hook that utilizes the include? Thanks.
Reply With Quote
  #2  
Old 24 Oct 2012, 18:32
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
The global_bootstrap_complete hook is called from inside a function (line 87 of class_bootstrap.php, if you want to se where), and there is no "global $vbulletin;" in that function, so $vbulletin isn't defined at that hook. Your function works because you do have the global statement. If you put "global $vbulletin;" in your plugin code it should work.
Reply With Quote
  #3  
Old 24 Oct 2012, 18:34
Revelence Revelence is offline
 
Join Date: Apr 2011
Real name: Joey
Originally Posted by kh99 View Post
The global_bootstrap_complete hook is called from inside a function (line 87 of class_bootstrap.php, if you want to se where), and there is no "global $vbulletin;" in that function, so $vbulletin isn't defined at that hook. Your function works because you do have the global statement. If you put "global $vbulletin;" in your plugin code it should work.
That's exactly what I was thinking, as I had a problem with something similar. Wasn't certain though so didn't post it.
Reply With Quote
  #4  
Old 24 Oct 2012, 19:13
DetroitYES's Avatar
DetroitYES DetroitYES is offline
 
Join Date: Mar 2009
Originally Posted by kh99 View Post
The global_bootstrap_complete hook is called from inside a function (line 87 of class_bootstrap.php, if you want to se where), and there is no "global $vbulletin;" in that function, so $vbulletin isn't defined at that hook. Your function works because you do have the global statement. If you put "global $vbulletin;" in your plugin code it should work.
Son of a gun. I swear on my life, this crossed my mind right before I hit the submit button on the thread, so I went and tried it to no avail.

Low and behold I just re-applied the change and it works as expected.

Thanks again.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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


New To Site? Need Help?

All times are GMT. The time now is 22:21.

Layout Options | Width: Wide Color: