diff options
author | Steve Clay <steve@mrclay.org> | 2012-11-25 16:49:34 -0500 |
---|---|---|
committer | Steve Clay <steve@mrclay.org> | 2012-11-25 16:59:52 -0500 |
commit | 646c0c13b75efb55940245e27ad5c281a8eadd67 (patch) | |
tree | 3cc69630068b8b737d6e545c285f66c4f6cb4cbc /engine | |
parent | 63cc3777af6922ab5de1f6f96bcc6ebe08e7caf2 (diff) | |
download | elgg-646c0c13b75efb55940245e27ad5c281a8eadd67.tar.gz elgg-646c0c13b75efb55940245e27ad5c281a8eadd67.tar.bz2 |
check entity cache first, and remove limit (from Paweł Sroka's branch)
Diffstat (limited to 'engine')
-rw-r--r-- | engine/lib/river.php | 29 |
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, + )); } /** |