PDA

View Full Version : Cron file for thread info updating ... HELP!?


deluxmall
02-10-2010, 08:21 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 the above 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');
}


?>

kh99
02-10-2010, 10:39 PM
I'm pretty sure it means that the database didn't open sucessfully. I've seen it happen before, but I can't remember what the problem turned out to be. I think maybe there's something you need in your file before the "require_once ('./global.php');". If you look at another "top level" file like misc.php for example, there's some stuff set up in there before the require_once. I have no idea off the top of my head what is actually needed or might be causing your problem (or even if that really is the problem, to be honest).

deluxmall
02-13-2010, 01:29 PM
i have copy the entire script .. but still not working.