]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #5551 removes corrupt entities from database
authorCash Costello <cash.costello@gmail.com>
Wed, 29 May 2013 11:52:19 +0000 (07:52 -0400)
committerCash Costello <cash.costello@gmail.com>
Wed, 29 May 2013 11:52:19 +0000 (07:52 -0400)
engine/lib/entities.php

index 15ab1170eb0dcec194e2a407d52ed20c828d19f5..7b4e0e15aefd4997ebbf5551ffcc1515e6b442e3 100644 (file)
@@ -2470,11 +2470,18 @@ function update_entity_last_action($guid, $posted = NULL) {
 function entities_gc() {
        global $CONFIG;
 
-       $tables = array ('sites_entity', 'objects_entity', 'groups_entity', 'users_entity');
+       $tables = array(
+               'site' => 'sites_entity',
+               'object' => 'objects_entity',
+               'group' => 'groups_entity',
+               'user' => 'users_entity'
+       );
 
-       foreach ($tables as $table) {
-               delete_data("DELETE from {$CONFIG->dbprefix}{$table}
-                       where guid NOT IN (SELECT guid from {$CONFIG->dbprefix}entities)");
+       foreach ($tables as $type => $table) {
+               delete_data("DELETE FROM {$CONFIG->dbprefix}{$table}
+                       WHERE guid NOT IN (SELECT guid FROM {$CONFIG->dbprefix}entities)");
+               delete_data("DELETE FROM {$CONFIG->dbprefix}entities
+                       WHERE type = '$type' AND guid NOT IN (SELECT guid FROM {$CONFIG->dbprefix}{$table})");
        }
 }