1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-28 12:30:42 +02:00

Some... fixes... laying around here.

git-svn-id: file:///svn/phpbb/trunk@6970 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2007-02-06 19:09:43 +00:00
parent 10f775cb1c
commit 333b3515ed
11 changed files with 115 additions and 88 deletions

View File

@@ -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);
}