aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2012-01-10 16:54:49 -0800
committerBrett Profitt <brett.profitt@gmail.com>2012-01-10 16:54:49 -0800
commita3f0353600e749a16abbdab3cbc75b3469d6fd69 (patch)
treefc534efde38eebc2db7b9b8d5044b9943dc93db2 /engine/lib
parent0fe0f9d6dc6577d39bf0615c0e714c7fa7d2ebf3 (diff)
downloadelgg-a3f0353600e749a16abbdab3cbc75b3469d6fd69.tar.gz
elgg-a3f0353600e749a16abbdab3cbc75b3469d6fd69.tar.bz2
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.
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/annotations.php2
-rw-r--r--engine/lib/metadata.php2
-rw-r--r--engine/lib/metastrings.php32
3 files changed, 32 insertions, 4 deletions
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index 7eb72612f..5049d455b 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -237,7 +237,7 @@ function elgg_disable_annotations(array $options) {
return false;
}
- $options['metastrings_type'] = 'annotations';
+ $options['metastring_type'] = 'annotations';
return elgg_batch_metastring_based_objects($options, 'elgg_batch_disable_callback');
}
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index a097cd3ef..19e8aa3c8 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -324,7 +324,7 @@ function elgg_disable_metadata(array $options) {
return false;
}
- $options['metastrings_type'] = 'metadata';
+ $options['metastring_type'] = 'metadata';
return elgg_batch_metastring_based_objects($options, 'elgg_batch_disable_callback');
}
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;
}
/**