]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Added entity caching to elgg_get_entities with workaround for recursive delete proble...
authorSteve Clay <steve@mrclay.org>
Wed, 13 Jun 2012 20:53:54 +0000 (16:53 -0400)
committerSteve Clay <steve@mrclay.org>
Wed, 13 Jun 2012 20:53:54 +0000 (16:53 -0400)
engine/lib/entities.php

index 20921b41a3c0e2b9fd1435ad73ad31990aeeba21..90e62fac725d16fe6bf4c2963f45721054b00d57 100644 (file)
@@ -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);