How to delete entities quickly ?

I disabled The Wire plugin, but the thewire entities are not deleted. They are still appeared on Search page (when the keyword is relevant). How to delete all TheWire entities quickly ?

  • To fetch and delete all wire postings it's best to write and execute a little php script that uses the Elgg API functions. Don't try to get rid of the wire postings by deleting stuff directly from the database because there would likely remain entries formerly connected with the deleted entries and in the worst case you break your database consistency.

    A script to find and delete wire postings can look like

    <?php
    $autoload_path = __DIR__ . '/vendor/autoload.php';
    $autoload_available = include_once($autoload_path);
    
    \Elgg\Application::start();
    
    if (elgg_is_admin_logged_in()) {
    
        $access = elgg_set_ignore_access(true);
        $access_status = access_get_show_hidden_status();
        access_show_hidden_entities(true);
    
        $entities = new ElggBatch('elgg_get_entities', array(
            'type' => 'object',
            'subtype' => 'thewire',
            'limit' => false,
        ));
    
        $entities->setIncrementOffset(false);
        $count = 0;
        foreach ($entities as $entity) {
            $entity->delete();
            $count++;
        }
    
        access_show_hidden_entities($access_status);
        elgg_set_ignore_access($access);
    }
    
    echo "Found and deleted " . $count . " wire postings.";

    Save it for example as wire_delete.php in the root folder of your Elgg installation and then call it in your browser while logged in as admin (url: your.site.url/wire_delete.php) and the wire entities will get deleted.

    In case you are still on Elgg 1, replace the lines

    $autoload_path = __DIR__ . '/vendor/autoload.php';
    $autoload_available = include_once($autoload_path);
    
    \Elgg\Application::start();


    with

    require 'engine/start.php';