aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2012-11-21 22:25:18 -0500
committerSteve Clay <steve@mrclay.org>2012-11-21 22:25:18 -0500
commit63cc3777af6922ab5de1f6f96bcc6ebe08e7caf2 (patch)
tree1f244553456ebb6b1c0473f15ab3733305c83f57 /engine/lib
parent19c6da97ed0178592b9041946f3463f9008dd7ea (diff)
downloadelgg-63cc3777af6922ab5de1f6f96bcc6ebe08e7caf2.tar.gz
elgg-63cc3777af6922ab5de1f6f96bcc6ebe08e7caf2.tar.bz2
Fixes #4926: prefetches entities to be displayed in river
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/river.php37
1 files changed, 36 insertions, 1 deletions
diff --git a/engine/lib/river.php b/engine/lib/river.php
index b717a7756..7bc3af9de 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -361,6 +361,7 @@ function elgg_get_river(array $options = array()) {
}
$river_items = get_data($query, 'elgg_row_to_elgg_river_item');
+ _elgg_prefetch_river_entities($river_items);
return $river_items;
} else {
@@ -370,11 +371,45 @@ function elgg_get_river(array $options = array()) {
}
/**
+ * Prefetch entities that will be displayed in the river.
+ *
+ * @param ElggRiverItem[] $river_items
+ * @access private
+ */
+function _elgg_prefetch_river_entities(array $river_items) {
+ // prefetch objects and subjects
+ $guids = array();
+ foreach ($river_items as $item) {
+ $guids[$item->object_guid] = true;
+ $guids[$item->subject_guid] = true;
+ if (count($guids) > 100) {
+ break;
+ }
+ }
+ // return value unneeded, just priming cache
+ elgg_get_entities(array('guids' => array_keys($guids)));
+
+ // prefetch object containers
+ $guids = array();
+ foreach ($river_items as $item) {
+ $object = $item->getObjectEntity();
+ if ($object) {
+ $guids[$object->container_guid] = true;
+ }
+ if (count($guids) > 100) {
+ break;
+ }
+ }
+ // return value unneeded, just priming cache
+ elgg_get_entities(array('guids' => array_keys($guids)));
+}
+
+/**
* List river items
*
* @param array $options Any options from elgg_get_river() plus:
* pagination => BOOL Display pagination links (true)
-
+ *
* @return string
* @since 1.8.0
*/