Announcement

Collapse
No announcement yet.

Delete all topics and users (API or DB)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Delete all topics and users (API or DB)

    Hi,

    I'm very new to VB, but after lots of testing i ended up with 150k topics/replies and 10k users
    Now i don't want to start fresh so i keep my other settings, but is there a fast way to delete all topics and replies. I use import scripts using VB_api calls to import our old forum data into VB. But i want to add something that on every import i first delete all existing topics and users and then import everything again. Since now it adds doubles every time.
    The channels, which also are the first node items, i want to keep.

    If i search in the vb_api docs, you can only delete by id. So then i first must find a search command to get all the IDs but the node -> fetchChannelNodeTree() doesn't return the full list.

    Can i maybe delete the nodes straight from the database using some vBForum query? But maybe there are relation tables that depends on these nodes?

    The prune option from de adminCP can't really handle this, and i want to run it automatically using the import script with vb_api or vBForum (or plain sql).

    Same goes for the users, only keep the default Admin user, delete all others.

    Thank you

  • #2
    You can delete topics in the AdminCP under Node Tools -> Prune.

    You can delete users in the AdminCP under Users -> Prune/Move Users.

    You cannot delete topics or users directly from the database without using irreperable harm. We do not have written instructions on using an API for this method. However, you can view the API at http://vb5support.com/resources/api/
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud customization and demonstration site.
    vBulletin 5 Documentation - Updated every Friday. Report issues here.
    vBulletin 5 API - Full / Mobile
    I am not currently available for vB Messenger Chats.

    Comment


    • #3
      Thanks.
      As mentioned i want to do this via import script.
      The prune function in adminCP always times out, and for the users prune, you can't delete if all are selected, then if says, please fill in all required fields.. You can only select like a few, and for few 10k users, thats a long clicking time for every import you want to run. If at least the select all and delete would work a bit and time out, you can maybe do it after few times, but now you can' since you have to deselect all and manual select a few. So that seems like a bug also then.
      I'm sure there must be a smarter en faster way via API of DB directly. I can not really believe all users use manual delete functions for all there test data which clearly doesn't even work in the adminCP as it should.

      If somebody can just point me a little in the direction of fetching all IDs with the API, then i can put them in the array and delete them, it only the fetching that doesn't seem to have a proper function (or simply a delete all function )
      Last edited by Jeroenb; Fri 7th Sep '18, 12:25am.

      Comment


      • #4
        Finally found it.
        For other users who want this:
        DELETE ALL USERS (not admin)

        $allUsers = $this->_vbApi->callApi('user', 'fetchPruneUsers', [-1, 0, 0, 0, 0]);
        foreach ($allUsers AS $user)
        {
        $this->_vbApi->callApi('user','delete', [$user['userid']]);
        }

        DELETE ALL TOPICS

        $params = ["conditions" => [
        0 => ["field" => "node.contenttypeid", "value" => "23", "operator" => "NE"],
        "node.sticky" => "0",
        1 => ["field" => "node.contenttypeid", "value" => "30", "operator" => "NE"]
        ],
        "channelinfo" => [],
        "special" => ["specialchannelid" => "7"]];
        $set = \vB::getDbAssertor()->assertQuery('vBForum:getThreadPrune', $params);
        $nodeids = array();
        foreach($set AS $row)
        {
        $nodeids[] = $row['nodeid'];
        }
        $this->_vbApi->callApi('node', 'deleteNodes', [$nodeids, true]);
        Last edited by Jeroenb; Fri 14th Sep '18, 2:19am.

        Comment

        Related Topics

        Collapse

        Working...
        X