Resource icon

Soft delete all moderated posts (queries)

Jake Bunce

Well-known member
Jake Bunce submitted a new resource:

Soft delete all moderated posts (queries) (version 1.x) - Useful for clearing out a backlog of moderated posts when you don't want to permanently delete them.

You can run these queries to soft delete all moderated posts. You need to change the red pieces to attribute these deletions to a user_id and username, as well as give the reason. These things are recorded in the deletion log:

Rich (BB code):
INSERT INTO xf_deletion_log (content_type, content_id, delete_date, delete_user_id, delete_username, delete_reason)
	SELECT content_type, content_id, UNIX_TIMESTAMP(), 1, 'admin', 'manually...

Read more about this resource...
 
Any query to hard delete all soft deleted posts? Thanks.
Edit, have deleted now all direct in phpmyadmin.

No. Hard deletes involves many tables, as well as attachments in the file system. There is no easy way to completely hard delete with queries.
 
No. Hard deletes involves many tables, as well as attachments in the file system. There is no easy way to completely hard delete with queries.

I just used successfully this code for softdeleting over 400 posts after a vbimport.

What happens now with these softdeletions, if I can not hard-delete them? Is there a performance downside? Is there a way to hard delete them as admin in the ACP of XF?
 
I just used successfully this code for softdeleting over 400 posts after a vbimport.

What happens now with these softdeletions, if I can not hard-delete them? Is there a performance downside? Is there a way to hard delete them as admin in the ACP of XF?

There is no good way to hard delete because it involves many joined records. Just leave them. There is no performance downside.
 
This is a great tip but it lacks support for profile posts.

Code:
INSERT INTO xf_deletion_log (content_type, content_id, delete_date, delete_user_id, delete_username, delete_reason)
    SELECT content_type, content_id, UNIX_TIMESTAMP(), 1, 'admin', 'manually moved from moderation to soft delete'
    FROM xf_moderation_queue AS mq
    WHERE mq.content_type = 'profile_post';

DELETE
FROM xf_moderation_queue
WHERE content_type = 'profile_post';

UPDATE xf_profile_post
SET message_state = 'deleted'
WHERE message_state = 'moderated';
 
Top Bottom