. // The forum tables contain items that can become inconsistent // due to bugs and DB gremlins. // This script repairs some of them. ini_set("memory_limit", "1024M"); $cli_only = true; require_once("../inc/forum_db.inc"); require_once("../inc/util_ops.inc"); db_init(); function update_thread_timestamps() { $threads = BoincThread::enum(); foreach ($threads as $thread) { $q = "select max(timestamp) as foo from post where thread=$thread->id"; $r2 = _mysql_query($q); $m = _mysql_fetch_object($r2); echo "id: $thread->id; min: $m->foo\n"; _mysql_free_result($r2); $n = $m->foo; if ($n) { $q = "update thread set timestamp=$n where id=$thread->id"; _mysql_query($q); } } } function update_user_posts() { $users = BoincUser::enum(""); foreach ($users as $user) { BoincForumPrefs::lookup($user); $num = BoincPost::count("user=$user->id"); if ($num != $user->prefs->posts) { echo "user $user->id: $user->posts $num\n"; $user->prefs->update("posts=$num"); } } } function update_thread_replies() { $threads = BoincThread::enum(); foreach ($threads as $t) { $n = BoincPost::count("thread=$t->id and hidden=0"); $n--; if ($t->replies != $n) { $t->update("replies=$n"); echo "updated thread $t->id; $t->replies -> $n\n"; } } } update_thread_timestamps(); update_user_posts(); update_thread_replies(); ?>