mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-08 16:45:19 +02:00
[feature/soft-delete] Fix sync('topic') to match the new logic
This also fixes set_post_visibility() PHPBB3-9567
This commit is contained in:
parent
2a81e4b48e
commit
63d11c976b
@ -212,7 +212,7 @@ 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)
|
else if ($is_starter && $topic_id)
|
||||||
{
|
{
|
||||||
// ... so we need to use sync, if the first post is changed.
|
// ... so we need to use sync, if the first post is changed.
|
||||||
// The forum is resynced recursive by sync() itself.
|
// The forum is resynced recursive by sync() itself.
|
||||||
|
@ -1889,6 +1889,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
|||||||
GROUP BY t.topic_id, t.post_visibility";
|
GROUP BY t.topic_id, t.post_visibility";
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$topic_firstlast_data = array();
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$topic_id = (int) $row['topic_id'];
|
$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)
|
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]['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;
|
$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);
|
$db->sql_freeresult($result);
|
||||||
|
@ -24,6 +24,15 @@
|
|||||||
<value>5</value>
|
<value>5</value>
|
||||||
<value>6</value>
|
<value>6</value>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<value>3</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>Only 1 Approved posts</value>
|
||||||
|
<value>8</value>
|
||||||
|
<value>8</value>
|
||||||
|
</row>
|
||||||
</table>
|
</table>
|
||||||
<table name="phpbb_posts">
|
<table name="phpbb_posts">
|
||||||
<column>post_id</column>
|
<column>post_id</column>
|
||||||
@ -89,6 +98,14 @@
|
|||||||
<value>2</value>
|
<value>2</value>
|
||||||
<value>Softdeleted</value>
|
<value>Softdeleted</value>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<value>8</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>3</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>1</value>
|
||||||
|
<value>Approved</value>
|
||||||
|
</row>
|
||||||
</table>
|
</table>
|
||||||
<table name="phpbb_users">
|
<table name="phpbb_users">
|
||||||
<column>user_id</column>
|
<column>user_id</column>
|
||||||
|
@ -34,7 +34,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
|
|||||||
array('post_id' => 3, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
array('post_id' => 3, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array('topic_visibility' => 1, 'topic_first_post_id' => '1', 'topic_last_post_id' => '2'),
|
array('topic_visibility' => 1, 'topic_first_post_id' => 1, 'topic_last_post_id' => 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -48,7 +48,21 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
|
|||||||
array('post_id' => 3, 'post_visibility' => 1, 'post_delete_reason' => 'approve'),
|
array('post_id' => 3, 'post_visibility' => 1, 'post_delete_reason' => 'approve'),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array('topic_visibility' => 1, 'topic_first_post_id' => '2', 'topic_last_post_id' => '3'),
|
array('topic_visibility' => 1, 'topic_first_post_id' => 2, 'topic_last_post_id' => 3),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
ITEM_DELETED,
|
||||||
|
2, 1, 1,
|
||||||
|
2, time(), 'deleted',
|
||||||
|
true, true,
|
||||||
|
array(
|
||||||
|
array('post_id' => 1, 'post_visibility' => 0, 'post_delete_reason' => ''),
|
||||||
|
array('post_id' => 2, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'),
|
||||||
|
array('post_id' => 3, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('topic_visibility' => 0, 'topic_first_post_id' => 1, 'topic_last_post_id' => 3),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -63,7 +77,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
|
|||||||
array('post_id' => 7, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
array('post_id' => 7, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array('topic_visibility' => 1, 'topic_first_post_id' => '6', 'topic_last_post_id' => '6'),
|
array('topic_visibility' => 1, 'topic_first_post_id' => 6, 'topic_last_post_id' => 6),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -73,12 +87,36 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
|
|||||||
false, true,
|
false, true,
|
||||||
array(
|
array(
|
||||||
array('post_id' => 4, 'post_visibility' => 0, 'post_delete_reason' => ''),
|
array('post_id' => 4, 'post_visibility' => 0, 'post_delete_reason' => ''),
|
||||||
array('post_id' => 5, 'post_visibility' => 1, 'post_delete_reason' => 'deleted'),
|
array('post_id' => 5, 'post_visibility' => 1, 'post_delete_reason' => ''),
|
||||||
array('post_id' => 6, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'),
|
array('post_id' => 6, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'),
|
||||||
array('post_id' => 7, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
array('post_id' => 7, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array('topic_visibility' => 1, 'topic_first_post_id' => '5', 'topic_last_post_id' => '5'),
|
array('topic_visibility' => 1, 'topic_first_post_id' => 5, 'topic_last_post_id' => 5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
ITEM_DELETED,
|
||||||
|
8, 3, 1,
|
||||||
|
2, time(), 'deleted',
|
||||||
|
true, true,
|
||||||
|
array(
|
||||||
|
array('post_id' => 8, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('topic_visibility' => 2, 'topic_first_post_id' => 8, 'topic_last_post_id' => 8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
ITEM_UNAPPROVED,
|
||||||
|
8, 3, 1,
|
||||||
|
2, time(), 'unapproved',
|
||||||
|
true, true,
|
||||||
|
array(
|
||||||
|
array('post_id' => 8, 'post_visibility' => 0, 'post_delete_reason' => 'unapproved'),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('topic_visibility' => 0, 'topic_first_post_id' => 8, 'topic_last_post_id' => 8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user