Journal Home Official Blog

3/4/2012 - How to moderate thousands of posts in vBulletin 3.x without timeout

Posted in PHP Code

I manage an old vBulletin (3.6.9) board and from time to time I need to moderate some posts/threads. One of the problems I have is, as the the only moderator, I sometime have 5000 or more posts/threads to moderate.

By default, vBulletin tries to display/moderate all the threads at once, this is ridiculous, even if your server can handle +5000 queries in one script your browser certainly cannot handle it, (you would need a truck load of memory to handle it).

So the best way is to edit the vBulletin code and limit the size of the posts been returned, that way you can moderate ~500 posts/threads at a time.

Look for the file called "moderate.php", it is found in the modcp folder.

Look for the code

  1. ...
  2. $moderated = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "moderation");
  3. ...

And add/replace the following limit checks to make sure it does not get out of hand.

  1. ...
  2. $moderated = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "moderation");
  3. while($moderate = $db->fetch_array($moderated))
  4. {
  5.  if($moderate['type'] == 'thread')
  6.  {
  7.   if(count($threadids) < 250)
  8.   {
  9.    $threadids[] = $moderate['threadid'];
  10.   }
  11.  }
  12.  else
  13.  {
  14.    if(count($threadids) < 500)
  15.    {
  16.      $postids[] = $moderate['postid'];
  17.    }
  18.   }
  19.   if(count($threadids) >= 500 && count($threadids) >= 250)
  20.   {
  21.     break;
  22.   }
  23. }
  24. ...

I know it would have been better to change the queries, (have 2 queries with type='thread' and limit of 250), but doing it this way makes it a little easier to explain.
Once you understand what is going on maybe you can change the code yourself to use more efficient queries.

The reason why I chose 250 threads and 500 posts? because, on my server, this seemed to be the safest way to prevent timeouts.

If you have version 4.x of vBulletin, I would be quite curious to hear how it works for you. I don't have that code, so I cannot say for sure if the same issue happens, (but I would hope that they fixed it).

Share |
Share and enjoy
  • Digg
  • DZone
  • Netvouz
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • YahooMyWeb

6/13/2012 -

Hello, can you make one such tutorial for vbulletin 4.x.x too? Thanks
Permanent Link

6/13/2012 -

Sorry I don't have 4.x so I can't really help you.
I purchased a 3.x license sometime ago and my forum never really got busy enough to warrant the, (very expensive), 4.x upgrade.
Permanent Link

8/27/2012 -

Sweet blog! I found it while browsing on Yahoo News. Do you have any tips on how to get listed in
Yahoo News? I've been trying for a while but I never seem to get there! Thank you
Permanent Link

10/22/2012 -

Do you do services for others? I mean, can you fix others' threads?
Permanent Link

10/25/2012 -

Permanent Link

11/6/2012 -

whoah this weblog is wonderful i like reading your posts.

Stay up the good work! You understand, a lot of people are hunting around for this info, you can help them greatly.
Permanent Link
<<Last Page • Next Page>>

About Me has created this blog for the purpose of keeping members and visitors up to date with site information.
The easiest way to stay up to date is by using the RSS/XML feed.
Place this URL within your rss aggregator and it will automatically update itself whenever a new journal entry is published.

«  March 2017  »


View my profile
Email Me
My Wall
Webmaster Forum
Free Blog
Follow JournalHome on Twitter


Ant Onaf
Silver Wind