Fix a divide by zero bug in PaginationHelper.php, a=chris
Fix a divide by zero bug in PaginationHelper.php, a=chris
diff --git a/src/views/helpers/PaginationHelper.php b/src/views/helpers/PaginationHelper.php
index fa2560845..d4e9228ab 100755
--- a/src/views/helpers/PaginationHelper.php
+++ b/src/views/helpers/PaginationHelper.php
@@ -46,7 +46,12 @@ class PaginationHelper extends Helper
* @var int
*/
const MAX_PAGES_TO_SHOW = 10;
-
+ /**
+ * The maximum numbered links to pages to show besides the next and
+ * previous links
+ * @var int
+ */
+ const MIN_RESULTS_PER_PAGE = 10;
/**
* Draws a strip of links which begins with a previous
* link (if their are previous pages of links) followed by up to
@@ -58,7 +63,8 @@ class PaginationHelper extends Helper
* @param int $limit the number of the first link to display in the
* set of search results.
* @param int $results_per_page how many links are displayed on a given
- * page of search results
+ * page of search results. The minimum value of this is
+ * self::MIN_RESULTS_PER_PAGE
* @param int $total_results the total number of search results for the
* current search term
* @param bool $micro whether to make a tiny pagination rather than normal
@@ -72,6 +78,7 @@ class PaginationHelper extends Helper
if ($_SERVER["MOBILE"] && $micro) {
return;
}
+ $results_per_page = max(self::MIN_RESULTS_PER_PAGE, $results_per_page);
$no_follow = ($no_follow) ? " rel='nofollow' " : "";
$num_earlier_pages = ceil($limit/$results_per_page);
$total_pages = ceil($total_results/$results_per_page);