[RFC|Accepted] Soft Delete

These requests for comments/change have lead to an implemented feature that has been successfully merged into the 3.1/Ascraeus branch. Everything listed in this forum will be available in phpBB 3.1.
Post Reply
Trapped inside rank factory, send help!
Posts: 334
Joined: Thu Aug 02, 2001 1:32 pm
Location: The Netherlands

Re: [RFC] Soft Delete

Post by BartVB » Sat Apr 10, 2010 7:48 am

code reader wrote:the database does not have any facility to store any field smaller than one byte, and in most database systems, there is no performance penalty up to 32 bits (i..e, reading int(8) or tinyint is not more expensive than reading int(1) (or bit), and usually it is not cheaper than reading plain int).
AFAIK MySQL can store BIT fields as 1 bit instead of 1 byte from version 5.1. Besides that there is a performance difference between TINYINT and INT, the latter requires four times more storage space which is especially problematic for something like the posts table that contains quite a few rows.

Another thing to take into consideration is that it's fairly hard to store bit fields and have them properly indexed. If you store them as *INT you won't be able to use an index.

In my case I've used negative values for quickdeleted posts. Besides that the system is pretty simple at the moment. A post is either:
1 : approved, everyone can view
0: not approved, only moderators can view
-1: quickdeleted, only moderators can view

In most cases users that can view unapproved posts can also view quickdeleted posts. In that case it's OK to add 'AND post_approved = 1' only if that user doesn't have these permissions.
I Hate oversized sigs and Love Penguins :D

User avatar
Registered User
Posts: 523
Joined: Sat Apr 22, 2006 10:29 pm

Re: [RFC] Soft Delete

Post by keith10456 » Thu Jun 10, 2010 11:48 pm

... Definitely would like to see this added to 3.1.

User avatar
Registered User
Posts: 1780
Joined: Wed Jun 04, 2003 4:23 pm

Re: [RFC] Soft Delete

Post by A_Jelly_Doughnut » Tue Jun 15, 2010 3:15 am

I am working on implementing this this week.

Below are my notes:

- Permissions
- m_delete - becomes m_harddelete
- m_softdelete - can soft delete posts in a forum
- m_restore - can restore soft-deleted posts in a forum. users with m_restore can also view soft-deleted posts.
- f_softdelete - user can soft delete own posts
- f_restore - user can restore own soft-deleted posts. users with f_restore can also view their own soft-deleted posts.
- f_delete - becomes f_harddelete

- repurpose "topic_approved" and "post_approved" to "topic_visibility" and "post_visibility"
+ This might allow "recycle wars" (depending on permissions) where a user bins his post repeatedly and moderator restores it. Allow setting post_edit_locked to resolve this.

- Constants
- ITEM_DELETED = 2 => has been soft deleted
- ITEM_UNAPPROVED = 0 => has not yet been approved
- ITEM_APPROVED = 1 => has been approved, and has not been soft deleted

- Functions
- get_visibility_sql($mode, $forum_id)
@param $mode string - either "topic" or "post"
@param $forum_id int - current forum ID
@return string with the appropriate combination SQL logic for topic/post_visibility
Description: Used to keep repetitive logic for determining topic/post visibility out of every file.
place in functions.php - needed on every page

- set_topic_visibility($visibility, $topic_id, $forum_id)
@param $visibility - int - one of the three constants above
@param $topic_id - int - topic ID to act on
@param $forum_id - int - forum ID where $topic_id resides
@return bool true = success, false = fail
Description: Allows approving (which is akin to undeleting), unapproving (!) or soft deleting an entire topic. Calls set_post_visibility as needed. Stored in functions_posting.php

- set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $is_starter, $is_latest)
@param $visibility - int - one of the three constants above
@param $post_id - int - the post ID to act on
@param $topic_id - int - forum where $post_id is found
@param $forum_id - int - forum ID where $topic_id resides
@param $is_starter - bool - is this the first post of the topic
@param $is_latest - bool - is this the last post of the topic
@return bool true = succes, false = fail
Description: Allows approving (which is akin to undeleting), unapproving (!) or soft deleting a single post. Stored in functions_posting.php

General Description:
A soft-delete feature (or recycle bin) allows users and moderators to soft-delete posts. This way, posts can be recovered should someone mistakenly delete a post.
The trash bin option will be separate from the hard delete option in all places in the user interface. A user/moderator can soft delete (assuming permissions) a post by clicking a 'trash can' icon. A user/moderator can undelete (assuming permissions) a post by clicking a 'trash can' icon. The difference between the two icons will be that the "soft delete" icon will have a "raised" look, and the "undelete" icon will appear depressed.
Users with permissions will see soft-deleted posts, with a flag at the top indicating them as such. These posts should therefore appear in the ATOM feeds.
In the MCP, soft-deleted posts will appear mostly the same way as posts on the moderation queue. I would rather just show "posts in trash bin" as one module rather than the two "unapproved posts" and "unapproved topics", but that's a minor change.
One thing I did not consider was pruning old soft-deleted posts. This would not be a difficult bolt-on, though.

Ticket: http://tracker.phpbb.com/browse/PHPBB3-9657

Registered User
Posts: 122
Joined: Tue Nov 11, 2008 5:44 pm

Re: [RFC] Soft Delete

Post by Nelsaidi » Tue Jun 15, 2010 10:35 am

Sounds good to me, fulfils the purpose and does exactly what it says on the tin.

User avatar
Registered User
Posts: 523
Joined: Sat Apr 22, 2006 10:29 pm

Re: [RFC] Soft Delete

Post by keith10456 » Tue Jun 15, 2010 4:34 pm

Thanks for the update... Glad to see forward progress on this :D

User avatar
Registered User
Posts: 986
Joined: Sun Feb 08, 2009 2:35 am
Location: Hollister, CA

Re: [RFC|Accepted] Soft Delete

Post by Pony99CA » Thu Oct 28, 2010 11:47 pm

Another state that would be useful is "saved". See the Save shouldn't have an interstital topic at phpBB.com.

That would make saving "fully functional" without losing attachments, polls, etc.

Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am

Re: [RFC|Accepted] Soft Delete

Post by Oleg » Sat Apr 30, 2011 4:18 pm

Work done so far:

https://github.com/jellydoughnut/phpbb3 ... oft-delete
(12:11:25) A_Jelly_Donut: feature complete AFAIK, but buggy
Note that the tree is branched off develop-olympus, and it refuses to rebase even on may 2010 develop.

Ticket: http://tracker.phpbb.com/browse/PHPBB3-9657

Registered User
Posts: 1
Joined: Sun Jan 31, 2010 7:23 am

Re: [RFC|Accepted] Soft Delete

Post by TiTex » Sun Dec 18, 2011 9:42 am

so will this be displayed similar to vbulletin on the board ?

User avatar
Former Team Member
Posts: 733
Joined: Sun Oct 07, 2007 11:54 am
Location: Stuttgart, Germany

Re: [RFC|Accepted] Soft Delete

Post by nickvergessen » Wed Aug 29, 2012 10:28 am

imkingdavid and I rebased the branch of A_Jelly_Donut onto develop
I now started to review the patch and fix it where needed.

The current implementation is however missing subsilver2.
Member of the Development-TeamNo Support via PM

User avatar
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: [RFC|Accepted] Soft Delete

Post by EXreaction » Wed Aug 29, 2012 10:24 pm

Kill ss2 and problem solved ^_^

Post Reply