diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2007-02-06 19:09:43 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2007-02-06 19:09:43 +0000 |
commit | 333b3515ed1e94dba1593b2eb3f9fb9d5a1f1440 (patch) | |
tree | 08a84c7c140f482b7e7917acc6bc6480e5b0ff43 /phpBB/includes/functions_admin.php | |
parent | 10f775cb1cc44b083373543a6c08214d1dd291f0 (diff) | |
download | forums-333b3515ed1e94dba1593b2eb3f9fb9d5a1f1440.tar forums-333b3515ed1e94dba1593b2eb3f9fb9d5a1f1440.tar.gz forums-333b3515ed1e94dba1593b2eb3f9fb9d5a1f1440.tar.bz2 forums-333b3515ed1e94dba1593b2eb3f9fb9d5a1f1440.tar.xz forums-333b3515ed1e94dba1593b2eb3f9fb9d5a1f1440.zip |
Some... fixes... laying around here.
git-svn-id: file:///svn/phpbb/trunk@6970 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_admin.php')
-rw-r--r-- | phpBB/includes/functions_admin.php | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 7208aee113..e0b7b8a554 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -598,7 +598,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = } $approved_posts = 0; - $post_ids = $topic_ids = $forum_ids = $post_counts = array(); + $post_ids = $topic_ids = $forum_ids = $post_counts = $remove_topics = array(); $sql = 'SELECT post_id, poster_id, post_approved, post_postcount, topic_id, forum_id FROM ' . POSTS_TABLE . ' @@ -653,6 +653,25 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = } } + // Remove topics now having no posts? + if (sizeof($topic_ids)) + { + $sql = 'SELECT topic_id + FROM ' . POSTS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' + GROUP BY topic_id'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $remove_topics[] = $row['topic_id']; + } + $db->sql_freeresult($result); + + // Actually, those not within remove_topics should be removed. ;) + $remove_topics = array_diff($topic_ids, $remove_topics); + } + // Remove the message from the search index $search_type = basename($config['search_type']); @@ -695,6 +714,12 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = set_config('num_posts', $config['num_posts'] - $approved_posts, true); } + // We actually remove topics now to not be inconsistent (the delete_topics function calls this function too) + if (sizeof($remove_topics)) + { + delete_topics('topic_id', $remove_topics); + } + return sizeof($post_ids); } |