clearing out old plugin entity/object types

i notice that traces of some plugins i have installed and then uninstalled remain in the database and appear in some places in the site; such as the account statistics panel in user settings..

e.g. izap_videos - count - remains in the statistics panel even though i have uninstalled it.

does the garbage collector clear these details out? is it perhaps not running on my site?

or is there another way to do this?

(elgg 1.8.8)

  • No, the garbage collector wont remove those entities from disabled plugins. This is situation with any Elgg plugin. If you disable a plugin, the entities, the plugin configuration settings etc are not removed from the DB. This is because in future if you re enable this plugin then you can continue with these entities and settings.

    If you need, you can delete these entries by a simple code, elgg_get_entities('subtype'=>'X'); and then deleting them.

  • ok sure; i think core needs ammending so whatever code searches for these objects does not include ones that can no longer be accessed due to plugins not being registered; an 'is_plugin_active' flagcheck.

    i looked for an elgg delete function in the reference - i found this:

    do you know if that is a suitable one? i didn't see any others that looked suitably named..

    thanks for assisting..

    nb. besides the objects not being registered and thus not visible; the language tags are no longer loaded so the text labels do not render, adding to the issues - though only ui-visibility related  

  • You don't want to delete metastrings - that is something garbage collection should do now.  It's the actual entities you want to delete.  I'm not sure of a good way to determine whether an object is provided by an inactive plugin... it's late though - I'll think on it.

  • object are defined with types & subtypes only - but are not related within the DM or in the DB to the *owning plugin* that creates & owns those entities & objects ;o( and therefore - only the entities {user & group} can be recognized as belonging 'somewhere' or to 'somebody' some plugin. all other entities are merely *objects with a *subtype qualifier.. so... cannot fetch an entity / object and know which *plugin has *created that - unless one reads thru the actual plugins' code for the object subtype literal reference(s) ;o( and so -- after disabling ' izap_videos', expect to forever see 'izap_videos_blahblah - count' in the statistics view. the only way to remove statistics displays for disabled plugins will be the plugin code browse just described - ir order to recognize objects whose owner plugins have been disabled ;oO{

  • it would be more better if Core team can provide a "Delete Button (X)"  against each entity in the page "Statistics : Overview" at Administration


  • i think both would be of use.. a way to hide entries in the statistics table (useful regardless of whether there are orphaned objects or not) && also a way to clear out objects of a particular object type in one go.

  • It would be a simple task to create a deletion script that an admin could trigger to clear out all objects of a specific subtype.



    function delete_by_subtype($object, $getter, $options) {

    $options = array('type' => 'object', 'subtype' => $subtype, 'limit' => 0);

    $batch = new ElggBatch('elgg_get_entities', $options, 'delete_by_subtype', 50);

  • Ohhh by reading all the above comemnts, it means all the plugins we use and after removing them still we have those plugins files, tables etc in our database? 

    I thought if I enebale and then remove the plugin then everything will be removed. It means I have lots of extra tables in in my elgg  site database :(


  • If the plugin was written properly you shouldn't have any additional tables in your database.  But you'll have entries in those tables from the plugin.

  • Few advices

    • Its better to not use plugins which alter Elgg's DB structure. 
    • Use only those plugins which you thinks as absolutely needed for your site.
    • Always rely on plugins from trusted Devs
    • Before using any plugin on your live site, test it well in a sandbox
    • Even if you wont understand anything from the code, take some time to go through the code, to detect any unknown calls to third party servers
    • Donot use plugins which load resources (JS) files from third party servers.

    If you are worried about those orphan DB entries, you can easily remove it by running the above code. It will remove all data associated with the entities.