cvs diff -u -N (in directory C:\CVS\drupalpatch) ? block-module.patch ? bootstrap.patch ? comment-module_0.patch ? drupal-module.patch ? forum-module_0.patch ? node_access_alias.patch ? noderev.patch ? poll_polled2.patch ? profile-module.patch ? pushbutton-header.patch ? statistics-module_0.patch ? stefan.patch ? system-module.patch ? taxonomy.patch ? taxorss.patch ? theme_settings.patch ? upload.patch ? user-module.patch cvs diff: Diffing . cvs diff: Diffing database cvs diff: Diffing includes Index: includes/pager.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/pager.inc,v retrieving revision 1.42 diff -u -r1.42 pager.inc --- includes/pager.inc 31 Mar 2005 09:25:33 -0000 1.42 +++ includes/pager.inc 24 May 2005 01:05:20 -0000 @@ -49,7 +49,7 @@ * @ingroup database */ function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) { - global $pager_from_array, $pager_total; + global $pager_from_array, $pager_total, $pager_total_items; $from = $_GET['from']; // Substitute in query arguments. @@ -68,13 +68,24 @@ // Convert comma-separated $from to an array, used by other functions. $pager_from_array = explode(',', $from); + // We calculate the total of pages as ceil(items / limit). + // For example, for limit = 10: + // items = 0 => total = 0 + // items = 5 => total = 1 + // items = 10 => total = 1 + // items = 11 => total = 2 + // items = 20 => total = 2 + // items = 21 => total = 3 if (count($args)) { - $pager_total[$element] = db_result(db_query($count_query, $args)); - return db_query_range($query, $args, (int)$pager_from_array[$element], (int)$limit); + $pager_total_items[$element] = db_result(db_query($count_query, $args)); + $pager_total[$element] = ceil($pager_total_items[$element] / $limit); + $pager_from_array[$element] = max(0, min($pager_total[$element])); + return db_query_range($query, $args, $pager_from_array[$element]*$limit, $limit); } else { - $pager_total[$element] = db_result(db_query($count_query)); - return db_query_range($query, (int)$pager_from_array[$element], (int)$limit); + $pager_total_items[$element] = db_result(db_query($count_query)); + $pager_total[$element] = ceil($pager_total_items[$element] / $limit); + return db_query_range($query, $pager_from_array[$element]*$limit, $limit); } } @@ -101,7 +112,7 @@ global $pager_total; $output = ''; - if ($pager_total[$element] > $limit) { + if ($pager_total[$element] > 1) { $output .= '