From d903ffd4e61689ddcac0f4cd046d2b9f800859f3 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 21 May 2024 14:20:18 +0000 Subject: [PATCH] Bug 36858: Check page parameter for virtual shelves Test plan: Try passing page=x now and verify different behavior (no 500). Signed-off-by: Marcel de Rooy Signed-off-by: David Nind Signed-off-by: Jonathan Druart Signed-off-by: Katrin Fischer (cherry picked from commit 90f011355735d16af8cdf6ef224ccf8074ad94e1) Signed-off-by: Fridolin Somers --- opac/opac-shelves.pl | 10 +++++----- virtualshelves/shelves.pl | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index 5cecfc7b96..9d5779948e 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -86,8 +86,9 @@ if (C4::Context->preference("BakerTaylorEnabled")) { ); } -my $referer = $query->param('referer') || $op; -my $public = 0; +my $referer = $query->param('referer') || $op; +my $page = int( $query->param('page') // q{} ) || 1; +my $public = 0; $public = 1 if $query->param('public') && $query->param('public') == 1; my ( $shelf, $shelfnumber, @messages ); @@ -315,10 +316,9 @@ if ( $op eq 'view' ) { $direction = 'asc' if !$direction or ( $direction ne 'asc' and $direction ne 'desc' ); $sortfield = 'title' if !$sortfield or !grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded ); - my ( $page, $rows ); + my $rows; unless ( $query->param('print') or $query->param('rss') ) { $rows = C4::Context->preference('OPACnumSearchResults') || 20; - $page = ( $query->param('page') ? $query->param('page') : 1 ); } my $order_by = $sortfield eq 'itemcallnumber' ? 'items.cn_sort' : $sortfield; my $contents = $shelf->get_contents->search( @@ -473,7 +473,7 @@ if ( $op eq 'view' ) { } } elsif ( $op eq 'list' ) { my $shelves; - my ( $page, $rows ) = ( $query->param('page') || 1, 20 ); + my ( $rows ) = ( 20 ); if ( !$public ) { $shelves = Koha::Virtualshelves->get_private_shelves({ page => $page, rows => $rows, borrowernumber => $loggedinuser, }); } else { diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index c0fd6737f0..cc2b658ce5 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -54,9 +54,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); -my $op = $query->param('op') || 'list'; -my $referer = $query->param('referer') || $op; -my $public = $query->param('public') ? 1 : 0; +my $op = $query->param('op') || 'list'; +my $referer = $query->param('referer') || $op; +my $page = int( $query->param('page') // q{} ) || 1; +my $public = $query->param('public') ? 1 : 0; my ( $shelf, $shelfnumber, @messages, $allow_transfer ); # PART1: Perform a few actions @@ -271,10 +272,9 @@ if ( $op eq 'view' ) { $sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded ); my $direction = $query->param('direction') || 'asc'; $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc'; - my ( $rows, $page ); + my $rows; unless ( $query->param('print') ) { $rows = C4::Context->preference('numSearchResults') || 20; - $page = ( $query->param('page') ? $query->param('page') : 1 ); } my $order_by = $sortfield eq 'itemcallnumber' ? 'items.cn_sort' : $sortfield; -- 2.39.5