aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2012-06-13 16:53:54 -0400
committerSteve Clay <steve@mrclay.org>2012-06-13 16:53:54 -0400
commite274214a3827f702b91639180433a7b534a303ef (patch)
treeedb08b71e04fc3d7786242853a29998fc8294ca6 /engine
parent6dafbe06733f6cee4a52b169f5e4cf07d9d11c72 (diff)
downloadelgg-e274214a3827f702b91639180433a7b534a303ef.tar.gz
elgg-e274214a3827f702b91639180433a7b534a303ef.tar.bz2
Added entity caching to elgg_get_entities with workaround for recursive delete problem (#4568)
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/entities.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 20921b41a..90e62fac7 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -77,7 +77,7 @@ function cache_entity(ElggEntity $entity) {
*
* @param int $guid The guid
*
- * @return void
+ * @return ElggEntity|bool false if entity not cached, or not fully loaded
* @see cache_entity()
* @see invalidate_cache_for_entity()
* @access private
@@ -954,13 +954,18 @@ function elgg_get_entities(array $options = array()) {
}
$dt = get_data($query, $options['callback']);
- foreach ($dt as $entity) {
- // If a custom callback is provided, it could return something other than ElggEntity,
- // so we have to do an explicit check here.
- if ($entity instanceof ElggEntity) {
- cache_entity($entity);
+ if ($dt) {
+ foreach ($dt as $entity) {
+ // If a custom callback is provided, it could return something other than ElggEntity,
+ // so we have to do an explicit check here.
+ if ($entity instanceof ElggEntity) {
+ cache_entity($entity);
+ }
}
+ // @todo Without this, recursive delete fails. See #4568
+ reset($dt);
}
+
return $dt;
} else {
$total = get_data_row($query);