The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Difference between $vbulletin->db and $db->
Hello all,
I think the code below which is within a plugin crashed my server! I was wondering if it was due to the use of $vbulletin->db and $db in the same function? For example: Code:
$search_sql = "SELECT threadid, title, lastpost, forumid, replycount, dateline, postuserid, visible, open FROM " . TABLE_PREFIX . "thread AS thread WHERE NOT ISNULL(threadid) AND visible = '1' AND replycount > '0' AND open!='10' AND forumid IN (".$forums_to_search.") $mp_stats_timecut_activethreads ORDER BY replycount DESC LIMIT 0, $num_of_threads_to_display"; $active_threads_result = $vbulletin->db->query_read($search_sql); $threadcount = $db->num_rows($active_threads_result); # now get the results and add to an array while ($thread_result = $db->fetch_array($active_threads_result)){ ...... { I copied the sql and code bits from a well known plugin mentioned in this forum and it worked well when I was the only one calling the plugin however when I added the plugin to the forum home template and accessible to the public my server used all its memory and swap and had to be rebooted. There are two code blocks in the plugin which execute SQL for stats (the other is along the same lines). I am unsure of why there are two access points used for the db calls ($vbulletin->db, $db) and I wonder if this is actually quite bad? For example wouldn't you go: Quote:
Quote:
Cheers Marc |
#2
|
||||
|
||||
PHP Code:
|
#3
|
|||
|
|||
Hello Dismounted,
Thank you for your reply. What I failed to mention in my first post is that the code is within a function and I have declared the following: Quote:
Cheers Marc |
#4
|
|||
|
|||
No, that code bit would not crash your server [necessarily]. We need to see the full plugin to evaluate it, there is also the possibility that the function is being run to many times causing the crash. There are a lot of possibilities.
|
#5
|
|||
|
|||
Hello Danny.VBT,
The plugin consists of code added to the plugin manager and a set of files stored outside the document root of the web site. The plugin code instantiates a class which does a few fews - one of them is to execute SQL against the forum db. Its a large class file so I have highlighted the main points below: 1. Uses pears cache_lite class - so when the plugin is called and the class loads it checks to see if the data is cached already. if so return the cache value if not continue with the data collection. I used cache_lite as I am told it has good file management (locking) etc.. 2) The class returns HTML data that the plugin then echos out. Below is the function in full that when added to the class called by the plugin the server crashed. Not sure if this did the damage but it was the last update. I also killed the cache files as well by deleting them. And the plugin code. Quote:
Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|