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 <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 90f0113557)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Marcel de Rooy 2024-05-21 14:20:18 +00:00 committed by Fridolin Somers
parent 509fd15d26
commit d903ffd4e6
2 changed files with 10 additions and 10 deletions

View file

@ -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 {

View file

@ -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;