Skip to content

Commit

Permalink
Fixes Elgg#1201 - Don't call getter after a previous count call retur…
Browse files Browse the repository at this point in the history
…ned 0 items
  • Loading branch information
Srokap authored and mrclay committed Aug 28, 2013
1 parent c80e48c commit 4e13295
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 11 additions & 3 deletions engine/lib/entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -1359,8 +1359,12 @@ function elgg_list_entities(array $options = array(), $getter = 'elgg_get_entiti
$options['count'] = true;
$count = call_user_func($getter, $options);

$options['count'] = false;
$entities = call_user_func($getter, $options);
if ($count > 0) {
$options['count'] = false;
$entities = call_user_func($getter, $options);
} else {
$entities = array();
}

$options['count'] = $count;

Expand Down Expand Up @@ -1842,7 +1846,11 @@ function elgg_list_registered_entities(array $options = array()) {

if (!empty($options['type_subtype_pairs'])) {
$count = elgg_get_entities(array_merge(array('count' => true), $options));
$entities = elgg_get_entities($options);
if ($count > 0) {
$entities = elgg_get_entities($options);
} else {
$entities = array();
}
} else {
$count = 0;
$entities = array();
Expand Down
8 changes: 6 additions & 2 deletions engine/lib/river.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,12 @@ function elgg_list_river(array $options = array()) {
$options['count'] = true;
$count = elgg_get_river($options);

$options['count'] = false;
$items = elgg_get_river($options);
if ($count > 0) {
$options['count'] = false;
$items = elgg_get_river($options);
} else {
$items = array();
}

$options['count'] = $count;
$options['items'] = $items;
Expand Down

0 comments on commit 4e13295

Please sign in to comment.