From 1804a89f77f1926db59aa039ec3b23105feca52c Mon Sep 17 00:00:00 2001 From: the_systech Date: Fri, 3 May 2002 19:46:34 +0000 Subject: [PATCH] Ok this should fix at least one of the issue with forum's getting out of sync... git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@2552 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_post.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_post.php b/phpBB/includes/functions_post.php index 901a1bbbda..f5af0a167f 100644 --- a/phpBB/includes/functions_post.php +++ b/phpBB/includes/functions_post.php @@ -524,12 +524,12 @@ function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } - $forum_update_sql = 'forum_posts = forum_posts - 1'; $topic_update_sql .= 'topic_replies = topic_replies - 1'; if ( $post_data['last_post'] ) { if ( $post_data['first_post'] ) { + $forum_update_sql .= ', forum_topics = forum_topics - 1'; $sql = "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = $topic_id OR topic_moved_id = $topic_id"; @@ -573,7 +573,22 @@ function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ } remove_search_post($post_id); - + // + // Ok we set variables above that were intended to update the topics table + // so let's go ahead and use it already :) + // + if( !empty($topic_update_sql) && !($post_data['first_post'] && $post_data['last_post']) ) + { + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET ' . $topic_update_sql . " + WHERE topic_id = $topic_id OR + topic_moved_id = $topic_id"; + if ( !($db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Error in updating reply counts', '', __LINE__, __FILE__, $sql); + } + } + if ( $mode == 'delete' && $post_data['first_post'] && $post_data['last_post'] ) { $meta = '';