From 138f82ef8ea7d4219b7c73cbd624ea7f137fc363 Mon Sep 17 00:00:00 2001 From: Graham Eames Date: Sun, 29 Jan 2006 17:31:16 +0000 Subject: [PATCH] Some slight changes to the pruning code This should improve performance for pruning on large forums Topics with no last_post_id are now dealt with separately git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@5508 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/prune.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/prune.php b/phpBB/includes/prune.php index 875d8aea1f..a01a08599e 100644 --- a/phpBB/includes/prune.php +++ b/phpBB/includes/prune.php @@ -31,6 +31,21 @@ function prune($forum_id, $prune_date, $prune_all = false) { global $db, $lang; + // Before pruning, lets try to clean up the invalid topic entries + $sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . ' + WHERE topic_last_post_id = 0'; + if ( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not obtain lists of topics to sync', '', __LINE__, __FILE__, $sql); + } + + while( $row = $db->sql_fetchrow($result) ) + { + sync('topic', $row['topic_id']); + } + + $db->sql_freeresult($result); + $prune_all = ($prune_all) ? '' : 'AND t.topic_vote = 0 AND t.topic_type <> ' . POST_ANNOUNCE; // // Those without polls and announcements ... unless told otherwise! @@ -39,8 +54,7 @@ function prune($forum_id, $prune_date, $prune_all = false) FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t WHERE t.forum_id = $forum_id $prune_all - AND ( p.post_id = t.topic_last_post_id - OR t.topic_last_post_id = 0 )"; + AND p.post_id = t.topic_last_post_id"; if ( $prune_date != '' ) { $sql .= " AND p.post_time < $prune_date";