Bug 7325 - Editing a list generates errors in the log
authorOwen Leonard <oleonard@myacpl.org>
Tue, 6 Dec 2011 21:03:31 +0000 (16:03 -0500)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 2 Jan 2012 22:46:13 +0000 (23:46 +0100)
Checking for variables before trying to use them in
building the pagination menu

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
C4/VirtualShelves/Page.pm

index 18535a5..523527e 100644 (file)
@@ -367,9 +367,9 @@ sub shelfpage ($$$$$) {
         $qhash{$_} = $query->param($_) if $query->param($_);
     }
     ( scalar keys %qhash ) and $url .= '?' . join '&', map { "$_=$qhash{$_}" } keys %qhash;
-    if ( $shelfnumber ) {
+    if ( $shelfnumber && $totitems ) {
         $template->param(  pagination_bar => pagination_bar( $url, ( int( $totitems / $shelflimit ) ) + ( ( $totitems % $shelflimit ) > 0 ? 1 : 0 ), $itemoff, "itemoff" )  );
-    } else {
+    } elsif ( $totshelves ) {
         $template->param(
              pagination_bar => pagination_bar( $url, ( int( $totshelves / $shelveslimit ) ) + ( ( $totshelves % $shelveslimit ) > 0 ? 1 : 0 ), $shelfoff, "shelfoff" )  );
     }