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

How does deleting work?

Discussion in 'XenForo Pre-Sales Questions' started by ActionMC, Jun 23, 2013.

  1. ActionMC

    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
     
  2. Claudio

    Claudio Well-Known Member

    As far as I know, if you delete a user, xenforo won't delete user's posts
     
  3. ActionMC

    ActionMC New Member

  4. Slavik

    Slavik XenForo Moderator Staff Member

    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.
     
  5. Chris D

    Chris D XenForo Developer Staff Member

    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.
     
    psTubble27 likes this.
  6. HWS

    HWS Well-Known Member

    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.
     
  7. Claudio

    Claudio Well-Known Member

    thank you for confirm this Chris. It would be useful to have a tool to delete all posts of a specific user
     
  8. Morgain

    Morgain Well-Known Member

    This would be possible through doing a user search and batch delete - I believe batch tools are on the way in 1.2
     
  9. Brogan

    Brogan XenForo Moderator Staff Member

    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. ActionMC

    ActionMC New Member

    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
     
  11. Brogan

    Brogan XenForo Moderator Staff Member

  12. Chris D

    Chris D XenForo Developer Staff Member

    It is indeed fixed in 1.2.

    Deleting a forum, deletes its threads.

    [​IMG]
     
  13. nodle

    nodle Well-Known Member

    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?
     
  14. Brogan

    Brogan XenForo Moderator Staff Member

    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.
     
  15. nodle

    nodle Well-Known Member

    This might be tough for alot of us that aren't this technical with SQL. :(
     
  16. Brogan

    Brogan XenForo Moderator Staff Member

    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.
     
    SneakyDave likes this.
  17. nodle

    nodle Well-Known Member

    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?
     
  18. Brogan

    Brogan XenForo Moderator Staff Member

    Yes.
    In which case perhaps the node ID is still the ID of the node which was deleted.
     
  19. Adam Howard

    Adam Howard Well-Known Member

    0 rows affected. ( Query took 0.0004 sec )

    Got the same thing.
     

Share This Page