commit 781e8f67d8a02bc85eeab106c688b87b5c601e9a
Author: Peter Bulmer <peter.bulmer@catalyst.net.nz>
Date:   Fri Aug 3 14:00:05 2007 +1200

    (weblib) fix for div-by-zero error. Explicitly handle perpage value of 0.

diff --git a/lib/weblib.php b/lib/weblib.php
index 451a4df..674e5bd 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -5365,7 +5365,12 @@ function print_paging_bar($totalcount, $
             $pagenum = $page - 1;
             $output .= '&nbsp;(<a  href="'. $baseurl . $pagevar .'='. $pagenum .'">'. get_string('previous') .'</a>)&nbsp;';
         }
-        $lastpage = ceil($totalcount / $perpage);
+        // Where $perpage is not defined, or zero - assume all results to be on single page
+        if (!empty($perpage)) {
+            $lastpage = ceil($totalcount / $perpage);
+        } else {
+            $lastpage = 0;
+        }
         if ($page > 15) {
             $startpage = $page - 10;
             $output .= '&nbsp;<a href="'. $baseurl . $pagevar .'=0">1</a>&nbsp;...';
