diff options
-rw-r--r-- | engine/lib/entities.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index b56f97dab..cb88fb455 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -2729,6 +2729,24 @@ if ((isloggedin()) && ($__RECURSIVE_DELETE_TOKEN) && (strcmp($__RECURSIVE_DELETE_TOKEN, md5(get_loggedin_userid()))))
return true;
+ } + + /** + * Garbage collect stub and fragments from any broken delete/create calls + * + * @param unknown_type $hook + * @param unknown_type $user + * @param unknown_type $returnvalue + * @param unknown_type $tag + */ + function entities_gc($hook, $user, $returnvalue, $tag) { + global $CONFIG; + + $tables = array ('sites_entity', 'objects_entity', 'groups_entity', 'users_entity'); + + foreach ($tables as $table) { + delete_data("DELETE from {$CONFIG->dbprefix}{$table} where guid NOT IN (SELECT guid from {$CONFIG->dbprefix}entities)"); + } }
/**
@@ -2741,7 +2759,9 @@ // Allow a permission override for recursive entity deletion
// TODO: Can this be done better?
- register_plugin_hook('permissions_check','all','recursive_delete_permissions_check');
+ register_plugin_hook('permissions_check','all','recursive_delete_permissions_check'); + + register_plugin_hook('gc','system','entities_gc');
}
/** Register the import hook */
|