aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/river.php
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2012-11-25 16:49:34 -0500
committerSteve Clay <steve@mrclay.org>2012-11-25 16:59:52 -0500
commit646c0c13b75efb55940245e27ad5c281a8eadd67 (patch)
tree3cc69630068b8b737d6e545c285f66c4f6cb4cbc /engine/lib/river.php
parent63cc3777af6922ab5de1f6f96bcc6ebe08e7caf2 (diff)
downloadelgg-646c0c13b75efb55940245e27ad5c281a8eadd67.tar.gz
elgg-646c0c13b75efb55940245e27ad5c281a8eadd67.tar.bz2
check entity cache first, and remove limit (from Paweł Sroka's branch)
Diffstat (limited to 'engine/lib/river.php')
-rw-r--r--engine/lib/river.php29
1 files changed, 18 insertions, 11 deletions
diff --git a/engine/lib/river.php b/engine/lib/river.php
index 7bc3af9de..133ef6de9 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -380,28 +380,35 @@ 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;
+ if ($item->subject_guid && !retrieve_cached_entity($item->subject_guid)) {
+ $guids[$item->subject_guid] = true;
+ }
+ if ($item->object_guid && !retrieve_cached_entity($item->object_guid)) {
+ $guids[$item->object_guid] = true;
}
}
+ // avoid creating oversized query
+ // @todo how to better handle this?
+ $guids = array_slice($guids, 0, 300, true);
// return value unneeded, just priming cache
- elgg_get_entities(array('guids' => array_keys($guids)));
+ elgg_get_entities(array(
+ 'guids' => array_keys($guids),
+ 'limit' => 0,
+ ));
// prefetch object containers
$guids = array();
foreach ($river_items as $item) {
$object = $item->getObjectEntity();
- if ($object) {
+ if ($object->container_guid && !retrieve_cached_entity($object->container_guid)) {
$guids[$object->container_guid] = true;
}
- if (count($guids) > 100) {
- break;
- }
}
- // return value unneeded, just priming cache
- elgg_get_entities(array('guids' => array_keys($guids)));
+ $guids = array_slice($guids, 0, 300, true);
+ elgg_get_entities(array(
+ 'guids' => array_keys($guids),
+ 'limit' => 0,
+ ));
}
/**