1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge pull request #6526 from marc1706/ticket/17029

[ticket/17029] Update post count when changing post visibility
This commit is contained in:
Marc Alexander
2023-10-01 13:59:05 +02:00
5 changed files with 188 additions and 23 deletions

View File

@@ -1345,7 +1345,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
{
$post_mode = 'delete_first_post';
}
else if ($data['topic_last_post_id'] == $post_id)
else if ($data['topic_last_post_id'] <= $post_id)
{
$post_mode = 'delete_last_post';
}
@@ -2872,7 +2872,14 @@ function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $
$delete_reason
));
$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=$next_post_id") . "#p$next_post_id";
if ($next_post_id > 0)
{
$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=$next_post_id") . "#p$next_post_id";
}
else
{
$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id");
}
$message = $user->lang['POST_DELETED'];
if (!$request->is_ajax())

View File

@@ -501,11 +501,15 @@ class content_visibility
$postcounts[$num_posts][] = $poster_id;
}
$postcount_change = 0;
// Update users postcounts
foreach ($postcounts as $num_posts => $poster_ids)
{
if (in_array($visibility, array(ITEM_REAPPROVE, ITEM_DELETED)))
{
$postcount_change -= $num_posts;
$sql = 'UPDATE ' . $this->users_table . '
SET user_posts = 0
WHERE ' . $this->db->sql_in_set('user_id', $poster_ids) . '
@@ -520,6 +524,8 @@ class content_visibility
}
else
{
$postcount_change += $num_posts;
$sql = 'UPDATE ' . $this->users_table . '
SET user_posts = user_posts + ' . $num_posts . '
WHERE ' . $this->db->sql_in_set('user_id', $poster_ids);
@@ -527,6 +533,11 @@ class content_visibility
}
}
if ($postcount_change != 0)
{
$this->config->increment('num_posts', $postcount_change, false);
}
$update_topic_postcount = true;
// Sync the first/last topic information if needed