From a3f0353600e749a16abbdab3cbc75b3469d6fd69 Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Tue, 10 Jan 2012 16:54:49 -0800 Subject: Fixes #4269. Not using ElggBatch to delete metadata / annotations. Added unit tests for deleting annotations/md. Fixed an annoying inconsistency with "metastring/s" option in private functions. --- engine/lib/metastrings.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'engine/lib/metastrings.php') diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index d8fef6f1c..62b60e279 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -727,10 +727,38 @@ function elgg_batch_metastring_based_objects(array $options, $callback) { return false; } - $batch = new ElggBatch('elgg_get_metastring_based_objects', $options, $callback); - $r = $batch->callbackResult; + switch($options['metastring_type']) { + case 'metadata': + $objects = elgg_get_metadata($options); + break; + + case 'annotations': + $objects = elgg_get_annotations($options); + break; + + default: + return false; + } + + if (!is_array($objects)) { + $r = false; + } elseif (empty($objects)) { + // ElggBatch returns null if the results are an empty array + $r = null; + } else { + $r = true; + foreach($objects as $object) { + $r = $r && $callback($object); + } + } return $r; + +// // @todo restore once ElggBatch supports callbacks that delete rows. +// $batch = new ElggBatch('elgg_get_metastring_based_objects', $options, $callback); +// $r = $batch->callbackResult; +// +// return $r; } /** -- cgit v1.2.3