aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2012-10-05 12:37:01 +0200
committerJoas Schilling <nickvergessen@gmx.de>2012-10-05 12:39:05 +0200
commit63d11c976b0bcef68ce4809c8c76124451df88ea (patch)
treec7627d8ef061678054764354cdecc1094e1cd4fa /phpBB
parent2a81e4b48ee223d8538e960b6e8e6e1c3e1277b2 (diff)
downloadforums-63d11c976b0bcef68ce4809c8c76124451df88ea.tar
forums-63d11c976b0bcef68ce4809c8c76124451df88ea.tar.gz
forums-63d11c976b0bcef68ce4809c8c76124451df88ea.tar.bz2
forums-63d11c976b0bcef68ce4809c8c76124451df88ea.tar.xz
forums-63d11c976b0bcef68ce4809c8c76124451df88ea.zip
[feature/soft-delete] Fix sync('topic') to match the new logic
This also fixes set_post_visibility() PHPBB3-9567
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/content_visibility.php2
-rw-r--r--phpBB/includes/functions_admin.php10
2 files changed, 11 insertions, 1 deletions
diff --git a/phpBB/includes/content_visibility.php b/phpBB/includes/content_visibility.php
index 112780224f..fbcdf27f08 100644
--- a/phpBB/includes/content_visibility.php
+++ b/phpBB/includes/content_visibility.php
@@ -212,7 +212,7 @@ class phpbb_content_visibility
update_post_information('forum', $forum_id, false);
}
}
- else if (($is_starter || $is_latest) && $topic_id)
+ else if ($is_starter && $topic_id)
{
// ... so we need to use sync, if the first post is changed.
// The forum is resynced recursive by sync() itself.
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index bb8b02bbea..04c99b5e62 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -1889,6 +1889,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
GROUP BY t.topic_id, t.post_visibility";
$result = $db->sql_query($sql);
+ $topic_firstlast_data = array();
while ($row = $db->sql_fetchrow($result))
{
$topic_id = (int) $row['topic_id'];
@@ -1911,10 +1912,19 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
if ($row['post_visibility'] == ITEM_APPROVED)
{
+ $topic_firstlast_data[$topic_id]['visibility'] = ITEM_APPROVED;
$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]['replies'] = $row['total_posts'] - 1;
}
+ else if (!isset($topic_firstlast_data[$topic_id]['visibility']) || $topic_firstlast_data[$topic_id]['visibility'] != ITEM_APPROVED)
+ {
+ // If there is no approved post, we take the min/max of the other visibilities
+ // for the last and first post info, because it is only visible to moderators anyway
+ $topic_data[$topic_id]['first_post_id'] = (!empty($topic_data[$topic_id]['first_post_id'])) ? min($topic_data[$topic_id]['first_post_id'], $row['first_post_id']) : $row['first_post_id'];
+ $topic_data[$topic_id]['last_post_id'] = max($topic_data[$topic_id]['last_post_id'], $row['last_post_id']);
+ $topic_firstlast_data[$topic_id]['visibility'] = $row['post_visibility'];
+ }
}
}
$db->sql_freeresult($result);