Log in

View Full Version : How to schedule "Rebuild Forum Information" ??


deluxmall
02-10-2010, 06:24 AM
I have created the following file to do CRON job for updating the thread info but i get the following error msg whenever I run it ....


Fatal error: Call to a member function query_first_slave() on a non-object in /xxx/yyy/zzz/global.php on line 242


Can anyone explain what it means???


<?php


require_once ('./global.php');
require_once('./includes/functions_databuild.php');

/*
updateCounters.php
*/

if (empty($vbulletin->GPC['perpage']))
{
$vbulletin->GPC['perpage'] = 100;
}

echo '<p>' . $vbphrase['updating_forums'] . '</p>';

$forums = $db->query_read("
SELECT forumid
FROM " . TABLE_PREFIX . "forum
WHERE forumid >= " . $vbulletin->GPC['startat'] . "
ORDER BY forumid
LIMIT " . $vbulletin->GPC['perpage']
);

$finishat = $vbulletin->GPC['startat'];

while($forum = $db->fetch_array($forums))
{
build_forum_counters($forum['forumid'], true);
echo construct_phrase($vbphrase['processing_x'], $forum['forumid']) . "<br />\n";
vbflush();

$finishat = ($forum['forumid'] > $finishat ? $forum['forumid'] : $finishat);
}

$finishat++;

if ($checkmore = $db->query_first("SELECT forumid FROM " . TABLE_PREFIX . "forum WHERE forumid >= $finishat LIMIT 1"))
{
print_cp_redirect("misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=updateforum&startat=$finishat&pp=" . $vbulletin->GPC['perpage']);
echo "<p><a href=\"misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=updateforum&amp;startat=$finishat&amp;pp=" . $vbulletin->GPC['perpage'] . "\">" . $vbphrase['click_here_to_continue_processing'] . "</a></p>";
}
else
{
// get rid of "ghost" moderators who are not attached to a valid forum
$deadmods = $db->query_read("
SELECT moderatorid
FROM " . TABLE_PREFIX . "moderator AS moderator
LEFT JOIN " . TABLE_PREFIX . "forum AS forum USING (forumid)
WHERE forum.forumid IS NULL AND forum.forumid <> -1
");

$mods = '';

while ($mod = $db->fetch_array($deadmods))
{
if (!empty($mods))
{
$mods .= ' , ';
}
$mods .= $mod['moderatorid'];
}

if (!empty($mods))
{
$db->query_write("DELETE FROM " . TABLE_PREFIX . "moderator WHERE moderatorid IN (" . $mods . ")");
}

// and finally rebuild the forumcache
unset($forumarraycache, $vbulletin->forumcache);
build_forum_permissions();

define('CP_REDIRECT', 'misc.php');
print_stop_message('updated_forum_successfully');
}


?>

--------------- Added 1265858468 at 1265858468 ---------------

any advice?

Marco van Herwaarden
02-11-2010, 10:19 AM
You are probably having issues with the current directory. Make sure to switch to the forum home directory before calling any includes.

PS What is the reason you are trying to run this from a cronjob, i assume you are talking about the operating system CRON and not the scheduled tasks inside vBulletin?

PPS What is the reason you want to run this at a regular interval anyway? Rebuilding information should only be ran if instructed. There is no reason to run it more often.