PDA

View Full Version : vBulletin and datastore


Marco
09-19-2008, 10:29 PM
Through a custom script (which runs outside of vBulletin), I am adding IP addresses to the vBulletin ban list. First I add it to the setting table, like so:

$banlist = mysql_fetch_array(mysql_query("SELECT value FROM setting WHERE varname = 'banip'"));
$addban = $banip . " " . $banlist['value'];
$updatebanlist = mysql_query("UPDATE setting SET value = '$addban' WHERE varname = 'banip'");

($banip is the IP address I am adding)

Because vBulletin also saves a cached copy of the options in the datastore table, I then refresh the options in the datastore like so:

$q = mysql_query("
SELECT varname,value
FROM setting"
);

while ($setting = mysql_fetch_array($q))
{
$newsetting[$setting['varname']] = $setting['value'];
}

$new_ds = serialize($newsetting);

mysql_query("
UPDATE datastore
SET data = '$new_ds'
WHERE title = 'options'
");

Up until recently (I have no idea what broke it), this was working great. Actually it still works; when I add an IP address, it gets added to the setting table, I can see it in the Admin CP - User Banning options and I can see through phpMyAdmin that it gets added to the datastore too. However, the IP ban still isn't effective until I manually save the User Banning options in the Admin CP.

This is driving me nuts and majorly pissing me off by now. Can anyone see what's wrong? I mean, the correct information is in the database, in both places ('setting' and 'datastore') yet vBulletin (3.7.3) doesn't seem to care. Is there maybe another place this information is cached?

(And no, I cannot use the build_options() function from vB, since I'm running a standalone script.)

Lynne
09-20-2008, 03:10 AM
Are you using datastore_cache? It needs to get added into there also (I think - I'm a total n00b when it comes to datastore_cache).

Marco
09-20-2008, 08:55 AM
We are not, but your post did put me on the right track! It turns out we are using APC now (we upgraded to PHP5 a few days ago) and that was the culprit. I put the following code at the end of my "datastore-update" code:

apc_delete("options");
apc_store("options", $new_ds);

It works great now. :)

oegis
09-20-2008, 12:08 PM
thanks.. very helpful

Lynne
09-20-2008, 02:15 PM
It works great now. :)
I'm glad I was able to trigger that lightbulb to go off in your head. :)