XF 2.1 Deleting thread are not delete post record

Nirjonadda

Well-known member
Batch update threads or manually Deleting thread are not delete post id from database. Deleted thread post have a post with ID in the database. xf_post table has a record with post_id=X, If we check any none-existing post, like /posts/7565654/ we will see the message is "The requested post could not be found." but for the page /posts/7/ the message is "You do not have permission to view this page or perform this action.". Deleted some threads, that removed the thread records but did not remove the posts for the same thread.
 
We run this query on our database to check for orphaned posts:

Code:
SELECT p.post_id, p.thread_id
FROM xf_post AS p
LEFT JOIN xf_thread AS t ON (t.thread_id = p.thread_id)
WHERE t.thread_id IS NULL

ScreenShot01167.webp

Thread ID 4 are deleted but post are not deleted.

ScreenShot01168.webp
 
The code is there to do that and in my testing a manual deletion or a batch deletion does clear the post records so this would indicate that the process is being interrupted by something else.

I can only suggest trying to repeat the process to see if it is consistently reproducible.

If it is, try the process again, but this time with all add-ons disabled.
 
@Chris D Please can you let me know that how to find posts which do not have valid thread numbers and delete of these orphaned posts from the xf_post and xf_deletion_log tables? Can you give SQL Query for this? We have 77737 posts have invalid thread numbers. We still not find out that why Batch update threads or manually Deleting thread are not delete post records from database.
 
I think ultimately it's just best to leave them - it won't affect anything and I'm not willing to run the risk of advising how to manually clear up data as it just opens up the possibility of orphaning even more data, or accidentally deleting too much.

It's not something we'll provide official support for.
 
We still not find out that why Batch update threads or manually Deleting thread are not delete post records from database.

Maybe thisone can help. Always remember: backup, backup, backup...

 
Last edited:
Top Bottom