• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How does deleting work?

#1
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
 

Slavik

XenForo moderator
Staff member
#4
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.
 

Chris D

XenForo developer
Staff member
#5
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.png

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.
 

HWS

Well-known member
#6
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.
 

Brogan

XenForo moderator
Staff member
#9
Batch Update Threads will allow you to mass delete threads started by a user, but not posts.

Batch Updates Users will not deal with threads nor posts.
 
#10
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
 

nodle

Well-known member
#13
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?
 

Brogan

XenForo moderator
Staff member
#14
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.
 

Brogan

XenForo moderator
Staff member
#16
I edited my post above.

Create a new "temp" forum.
Node the node ID.
Edit the query above with the node ID, changing 99 to suit.
Then delete the node.
 

nodle

Well-known member
#17
I edited my post above.

Create a new "temp" forum.
Node the node ID.
Edit the query above with the node ID, changing 99 to suit.
Then delete the node.
I ran this then I got this:

Code:
0 rows affected. ( Query took 0.0006 sec )
Does that mean that it couldn't find any?