I need to create a task that performs the same function as the recount_rebuild.php file in MyBB to automatically recount the forums and threads every 1 minute. This is the code I use as a task in MyBB, but the execution does not seem to have worked, the values presented on the home page are the same:
<?php
require_once 'global.php';
require_once MYBB_ROOT.'inc/functions_rebuild.php';
require_once MYBB_ROOT.'inc/functions.php';
function task_recount_rebuild_forum_counters($task)
{
global $db, $mybb, $lang;
$query = $db->simple_select("forums", "fid", '', array('order_by' => 'fid', 'order_dir' => 'asc'));
while($forum = $db->fetch_array($query))
{
$update['parentlist'] = make_parent_list($forum['fid']);
$db->update_query("forums", $update, "fid='{$forum['fid']}'");
rebuild_forum_counters($forum['fid']);
}
}
function task_recount_rebuild_thread_counters($task)
{
global $db, $mybb, $lang;
$query = $db->simple_select("threads", "tid", '', array('order_by' => 'tid', 'order_dir' => 'asc'));
while($thread = $db->fetch_array($query))
{
rebuild_thread_counters($thread['tid']);
}
}
2
Answers
I managed to solve the problem with the following code
Você me salvou nessa! Tinha acabado de jogar fora o código que achei, pois não funcionava direito. Aí encontrei essa postagem sua. Seu código funcionou pra mim! Obrigado!