How does deleting work?

ActionMC

New member
How does deleting work in xenForo? if i delete a thread, can i be sure anything that references that thread (posts, alerts, likes etc) will all be deleted or will there be "dead" data in the database after the thread is deleted. If xenforo uses the cascade delete model (delete thread will delete everything that the thread references), does it do it at delete time or with a cron? If not, are there any 3rd party solutions to clean up the database?

thanks
 
If you hard delete a thread it is gone, and all references to it also. Alerts will show the alert balloon, but will not show what it was about (it just disapears when they hover it).

If someone has quoted parts of said thread elsewhere (ie not in the deleted thread) those references will remain obviously.

There is no need for any "database cleanup", as it is all handled by XenForo when the delete is done.
 
There are some pieces of data which are deliberately left over... but on the whole XenForo uses the DataWriter for database write and delete operations.

So in the example of threads, if a thread is deleted and it has a poll attached then all poll related information for that thread is deleted too (at delete time).

In the example of users, here's a look at some of the stuff that happens:

upload_2013-6-23_21-24-25.webp

So you can see that quite a lot of attention is paid generally to ensuring no orphaned records are left. And that's only part of the function in the user DataWriter.

@Claudio Ba is right. Posts aren't deleted when you delete the user. But instead all content made by that user is attributed to user_id = 0 which is the Guest user.
 
Usually deleting a thread does also delete all additional data like posts, alerts and like.
However deleting a forum does NOT delete it's threads. But this may have changed in 1.2.
Deleting a user also does not delete his posts and threads.

So this is different depending on what you delete.
 
Usually deleting a thread does also delete all additional data like posts, alerts and like.
However deleting a forum does NOT delete it's threads. But this may have changed in 1.2.
Deleting a user also does not delete his posts and threads.

So this is different depending on what you delete.

That seems like it could leave some serious dead data in the db as there will be no way to access the threads after you delete the forum. Hope its fixed in 1.2
 
It is indeed fixed in 1.2.

Deleting a forum, deletes its threads.

lunapic_132009218615037_9.gif
 
Question though. For use that are not running 1.2 when we update to 1.2, will it then go back and clean up the database for us? Because I deleted some large forums, and it would be nice to slim the database size back down. Just wondering if the upgrade will work this way?
 
The fix is not retroactive so orphaned threads won't be deleted.

You will need to associate them with a forum (node ID) using SQL and then delete the forum.

Not sure what the node ID is for orphaned threads is but I'll take a guess at 0.
Code:
UPDATE xf_thread
SET node_id = 99
WHERE node_id = 0

So that query will attach all threads which are orphaned to node ID 99.
 
Back
Top Bottom