PDA

View Full Version : Plugins and vB Settings


TheMayhem
08-29-2010, 01:39 AM
I have spent most of my night trying to debug my product and finally zero'd in on a problem that users have been reporting since vB 4.0.2. I wasn't able to find any documentation or bug related issues so I figured I'd ask the forum in general if anyone knew.

For a very small portion of the people who use my product, the stored data in vbulletin settings are not working correctly in plugins. For nearly 95% of the users on hooks, I can use something like:

$grab = $vbulletin->options['market_gift_postbit']

And $grab would get the correct numerical or data value stored in the vbulleting database settings. However, for that remaining 5% of the users, it absolutely refuses to find out what $grab is and I cannot figure out why. It's been an issue since vbulletin version 4.0.2. The above example for those 5% of users would display nothing if I decided to echo it out or use it in an if statement, regardless of what data is stored.

The vbulletin settings are working perfectly fine on my files, the problem is only occurying when I try to use the above example in a plugin such as postbit_display_complete. Any help/advise would be appreciated.

Lynne
08-29-2010, 01:46 AM
You need to make sure $vbulletin is in scope. You may need to make $vbulletin global at the top of your plugin code. (Or, it could be the $vbulletin is just the wrong variable - if you look at that hook location, you'll see that $this->registry may be the way to call the setting ie. $this->registry->options['market_gift_postbit']. When in doubt, go find the hook location and look at the code around it.

Guest190829
08-29-2010, 01:48 AM
Try doing some cross diagnosis between the forums that are causing your product to malfunction:

Are the x% of forums experiencing problems running the same version of vB ?

Do they have any of the same third-party products installed?

etc,etc...

This will help determine if it's a vBulletin version incompatibility or a conflict with another product perhaps.

TheMayhem
08-30-2010, 07:59 PM
Ok I did a far more pinpoint after 8 hours of adding, testing, editing, and deleting code and here is what I have found. On the postbit plugins (postbit_display_start and postbit_display_complete) the usage of mysql is not working. So to test it to the extreme, I uninstalled my product and had a blank version of vBulletin.

I created a test plugin in postbit_display_complete:


$grabexperience = $db->fetch_array($db->query_read("SELECT username FROM " . TABLE_PREFIX . "user"));

print "$grabexperience[username] is working!!! or not";


It produced a pretty blank page and my showthread didn't load correctly. If I tried deleting that and just calling upon any vBulletin saved setting, I received no error but it did not find the data correctly. What can I do guys?

Lynne
08-31-2010, 12:28 AM
If you show the errors, you'll see this error with that call:

Fatal error: Call to a member function fetch_array() on a non-object in /home/thetradersden/public_html/vb4_suite2/includes/class_postbit.php(321) : eval()'d code on line 39

The reason I suggested you actually look at the code where the hook is was so you could see what syntax was being used there. If you did, you'd see the proper syntax there is not $db, but instead $this->registry->db .