Permalink
Browse files

fix(views): listing of entities and river no longer count if not needed

fixes #11807
  • Loading branch information...
jdalsem committed Mar 27, 2018
1 parent 759873d commit ee6a043eb57abb4e93594643b5b484ebe55a239f
Showing with 41 additions and 22 deletions.
  1. +20 −11 engine/lib/entities.php
  2. +21 −11 engine/lib/river.php
View
@@ -414,18 +414,27 @@ function elgg_list_entities(array $options = array(), $getter = 'elgg_get_entiti
$options['list_type_toggle'] = $options['view_type_toggle'];
}
$options['count'] = true;
$count = call_user_func($getter, $options);
if ($count > 0) {
$options['count'] = false;
$entities = call_user_func($getter, $options);
} else {
$entities = array();
$options['count'] = false;
$entities = call_user_func($getter, $options);
$options['count'] = is_array($entities) ? count($entities) : 0;
if (!empty($entities)) {
$count_needed = true;
if (!$options['pagination']) {
$count_needed = false;
} elseif (!$options['offset'] && !$options['limit']) {
$count_needed = false;
} elseif (($options['count'] < (int) $options['limit']) && !$options['offset']) {
$count_needed = false;
}
if ($count_needed) {
$options['count'] = true;
$options['count'] = (int) call_user_func($getter, $options);
}
}
$options['count'] = $count;
return call_user_func($viewer, $entities, $options);
}
View
@@ -455,18 +455,28 @@ function elgg_list_river(array $options = array()) {
// no need for pagination if listing is unlimited
$options["pagination"] = false;
}
$options['count'] = true;
$count = elgg_get_river($options);
if ($count > 0) {
$options['count'] = false;
$items = elgg_get_river($options);
} else {
$items = array();
$options['count'] = false;
$items = elgg_get_river($options);
$options['count'] = is_array($items) ? count($items) : 0;
if (!empty($items)) {
$count_needed = true;
if (!$options['pagination']) {
$count_needed = false;
} elseif (!$options['offset'] && !$options['limit']) {
$count_needed = false;
} elseif (($options['count'] < (int) $options['limit']) && !$options['offset']) {
$count_needed = false;
}
if ($count_needed) {
$options['count'] = true;
$options['count'] = (int) elgg_get_river($options);
}
}
$options['count'] = $count;
$options['items'] = $items;
return elgg_view('page/components/list', $options);

0 comments on commit ee6a043

Please sign in to comment.