Index: functions_admin.php =================================================================== --- functions_admin.php (revision 1232) +++ functions_admin.php (working copy) @@ -523,21 +523,18 @@ AND forum_id = ' . $forum_id; $db->sql_query($sql); - if ($auto_sync) + $sql = 'SELECT DISTINCT forum_id + FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_id', $topic_ids); + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) { - $sql = 'SELECT DISTINCT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $forum_ids[] = $row['forum_id']; - } - $db->sql_freeresult($result); + $forum_ids[] = $row['forum_id']; } + $db->sql_freeresult($result); - $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); + $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE); foreach ($table_ary as $table) { $sql = "UPDATE $table @@ -547,6 +544,12 @@ } unset($table_ary); + /* This table has no index on topic_id, but it does have an index on forum_id */ + $sql = "UPDATE " . TOPICS_TRACK_TABLE . " + SET forum_id = $forum_id + WHERE " . $db->sql_in_set('topic_id', $topic_ids)." AND ". $db->sql_in_set('forum_id', $forum_ids); + $db->sql_query($sql); + if ($auto_sync) { sync('forum', 'forum_id', $forum_ids, true, true);