mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-04 06:39:14 +02:00
[feature/soft-delete] Add test case for (soft)deleting the only post + fix
PHPBB3-9567
This commit is contained in:
parent
44005f338e
commit
25804eb8e8
@ -416,7 +416,7 @@ class phpbb_content_visibility
|
||||
$forum_id_list[$post_data['forum_id']] = 1;
|
||||
}
|
||||
|
||||
// User post update (we do not care about topic or post, since user posts are strictly connected to posts)
|
||||
// User post update (we do not care about topic or post, since user topics are strictly connected to posts)
|
||||
// But we care about forums where post counts get not increased. ;)
|
||||
if ($post_data['post_postcount'])
|
||||
{
|
||||
|
@ -1461,11 +1461,11 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
|
||||
}
|
||||
|
||||
// (Soft) delete the post
|
||||
if ($is_soft)
|
||||
if ($is_soft && ($post_mode != 'delete_topic'))
|
||||
{
|
||||
phpbb_content_visibility::set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, $user->data['user_id'], time(), $softdelete_reason, ($data['topic_first_post_id'] == $post_id), ($data['topic_last_post_id'] == $post_id));
|
||||
}
|
||||
else
|
||||
else if (!$is_soft)
|
||||
{
|
||||
if (!delete_posts('post_id', array($post_id), false, false))
|
||||
{
|
||||
@ -1502,7 +1502,6 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
|
||||
{
|
||||
$topic_row = array();
|
||||
phpbb_content_visibility::set_topic_visibility(ITEM_DELETED, $topic_id, $forum_id, $user->data['user_id'], time(), $softdelete_reason);
|
||||
phpbb_content_visibility::remove_topic_from_statistic($topic_id, $forum_id, $topic_row, $sql_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -186,6 +186,61 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
|
||||
array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 2),
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
2, 2, 4,
|
||||
array(
|
||||
'topic_first_post_id' => 4,
|
||||
'topic_last_post_id' => 4,
|
||||
'topic_replies_real' => 0,
|
||||
'topic_visibility' => ITEM_APPROVED,
|
||||
'post_time' => 4,
|
||||
'post_visibility' => ITEM_APPROVED,
|
||||
'post_postcount' => true,
|
||||
'poster_id' => 1,
|
||||
'post_reported' => false,
|
||||
),
|
||||
false, 'harddelete',
|
||||
array(
|
||||
),
|
||||
array(
|
||||
),
|
||||
array(
|
||||
array('forum_posts' => 0, 'forum_topics' => 0, 'forum_topics_real' => 0, 'forum_last_post_id' => 0),
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
2, 2, 4,
|
||||
array(
|
||||
'topic_first_post_id' => 4,
|
||||
'topic_last_post_id' => 4,
|
||||
'topic_replies_real' => 0,
|
||||
'topic_visibility' => ITEM_APPROVED,
|
||||
'post_time' => 4,
|
||||
'post_visibility' => ITEM_APPROVED,
|
||||
'post_postcount' => true,
|
||||
'poster_id' => 1,
|
||||
'post_reported' => false,
|
||||
),
|
||||
true, 'soft delete',
|
||||
array(
|
||||
array('post_id' => 4, 'post_visibility' => ITEM_DELETED, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'topic_visibility' => ITEM_DELETED,
|
||||
'topic_first_post_id' => 4,
|
||||
'topic_last_post_id' => 4,
|
||||
'topic_replies' => 0,
|
||||
'topic_replies_real' => 0,
|
||||
'topic_delete_reason' => 'soft delete',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array('forum_posts' => 0, 'forum_topics' => 0, 'forum_topics_real' => 1, 'forum_last_post_id' => 0),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,15 @@
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>4</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_topics">
|
||||
<column>topic_id</column>
|
||||
@ -45,6 +54,19 @@
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
<value>4</value>
|
||||
<value>4</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_posts">
|
||||
<column>post_id</column>
|
||||
@ -93,6 +115,19 @@
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<value>4</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>4</value>
|
||||
<value>Approved</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_users">
|
||||
<column>user_id</column>
|
||||
|
Loading…
x
Reference in New Issue
Block a user