aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-03-06 15:49:31 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-03-06 15:49:31 +0000
commitb8dda4616e325cd8b6e97020829adbc6810e1e02 (patch)
tree0c78c25988a98da42dfaf635753d36a23b5b54c3
parentfc05d0e128fb69ae100de9bb089727bfa7baa239 (diff)
downloadelgg-b8dda4616e325cd8b6e97020829adbc6810e1e02.tar.gz
elgg-b8dda4616e325cd8b6e97020829adbc6810e1e02.tar.bz2
Added garbage collector hook to clear up orphaned sub table entities.
git-svn-id: https://code.elgg.org/elgg/trunk@3116 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/entities.php22
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 */