mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/soft-delete] Fix a bug in sync() and set_post_visibility()
PHPBB3-9657
This commit is contained in:
parent
1f8f07b998
commit
5b64ebc11d
2 changed files with 11 additions and 10 deletions
|
@ -242,12 +242,6 @@ class phpbb_content_visibility
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
// if we're changing the starter, we need to change the rest of the topic
|
|
||||||
if ($is_starter && !$is_latest)
|
|
||||||
{
|
|
||||||
return self::set_topic_visibility($visibility, $topic_id, $forum_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($post_id)
|
if ($post_id)
|
||||||
{
|
{
|
||||||
$where_sql = 'post_id = ' . (int) $post_id;
|
$where_sql = 'post_id = ' . (int) $post_id;
|
||||||
|
@ -274,8 +268,9 @@ class phpbb_content_visibility
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
||||||
// Sync the first/last topic information if needed
|
// Sync the first/last topic information if needed
|
||||||
if ($is_starter || $is_latest)
|
if (!$is_starter && $is_latest)
|
||||||
{
|
{
|
||||||
|
// update_post_information can only update the last post info ...
|
||||||
if ($topic_id)
|
if ($topic_id)
|
||||||
{
|
{
|
||||||
update_post_information('topic', $topic_id, false);
|
update_post_information('topic', $topic_id, false);
|
||||||
|
@ -285,6 +280,12 @@ class phpbb_content_visibility
|
||||||
update_post_information('forum', $forum_id, false);
|
update_post_information('forum', $forum_id, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (($is_starter || $is_latest) && $topic_id)
|
||||||
|
{
|
||||||
|
// ... so we need to use sync, if the first post is changed.
|
||||||
|
// The forum is resynced recursive by sync() itself.
|
||||||
|
sync('topic', 'topic_id', $topic_id, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1908,12 +1908,12 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||||
unset($delete_topics[$topic_id]);
|
unset($delete_topics[$topic_id]);
|
||||||
|
|
||||||
$topic_data[$topic_id]['replies_real'] += $row['total_posts'];
|
$topic_data[$topic_id]['replies_real'] += $row['total_posts'];
|
||||||
$topic_data[$topic_id]['first_post_id'] = (!$topic_data[$topic_id]['first_post_id']) ? $row['first_post_id'] : min($topic_data[$topic_id]['first_post_id'], $row['first_post_id']);
|
|
||||||
|
|
||||||
if ($row['post_visibility'] || !$topic_data[$topic_id]['last_post_id'])
|
if ($row['post_visibility'] == ITEM_APPROVED)
|
||||||
{
|
{
|
||||||
$topic_data[$topic_id]['replies'] = $row['total_posts'] - 1;
|
$topic_data[$topic_id]['first_post_id'] = $row['first_post_id'];
|
||||||
$topic_data[$topic_id]['last_post_id'] = $row['last_post_id'];
|
$topic_data[$topic_id]['last_post_id'] = $row['last_post_id'];
|
||||||
|
$topic_data[$topic_id]['replies'] = $row['total_posts'] - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue