diff options
| author | Brett Profitt <brett.profitt@gmail.com> | 2012-01-25 21:46:20 -0800 | 
|---|---|---|
| committer | Brett Profitt <brett.profitt@gmail.com> | 2012-01-25 21:46:20 -0800 | 
| commit | 4202d7d3087db4f503a7586a1f3fc824ebf45b30 (patch) | |
| tree | 5c120eb9080425569f322668e1896becd9fb5e5c /engine/lib | |
| parent | 6a2d3d7c2d22f57f28472d9d023788d20d41f005 (diff) | |
| download | elgg-4202d7d3087db4f503a7586a1f3fc824ebf45b30.tar.gz elgg-4202d7d3087db4f503a7586a1f3fc824ebf45b30.tar.bz2  | |
Fixes #4081. Using ElggBatch to delete recursive.
Diffstat (limited to 'engine/lib')
| -rw-r--r-- | engine/lib/entities.php | 28 | 
1 files changed, 16 insertions, 12 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 2dc0eb8ae..c1ef683e5 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -1520,18 +1520,22 @@ function delete_entity($guid, $recursive = true) {  					$entity_disable_override = access_get_show_hidden_status();  					access_show_hidden_entities(true);  					$ia = elgg_set_ignore_access(true); -					$sub_entities = get_data("SELECT * from {$CONFIG->dbprefix}entities -						WHERE container_guid=$guid -							or owner_guid=$guid -							or site_guid=$guid", 'entity_row_to_elggstar'); -					if ($sub_entities) { -						foreach ($sub_entities as $e) { -							// check for equality so that an entity that is its own -							// owner or container does not cause infinite loop -							if ($e->guid != $guid) { -								$e->delete(true); -							} -						} + +					// @todo there was logic in the original code that ignored +					// entities with owner or container guids of themselves. +					// this should probably be prevented in ElggEntity instead of checked for here +					$options = array( +						'wheres' => array( +							"((container_guid = $guid OR owner_guid = $guid OR site_guid = $guid)" +							. " AND guid != $guid)" +							), +						'limit' => 0 +					); + +					$batch = new ElggBatch('elgg_get_entities', $options, 50, false); + +					foreach ($batch as $e) { +						$e->delete(true);  					}  					access_show_hidden_entities($entity_disable_override);  | 
