From ea51ef0162f8431d3836d3a1d0059e91c22f720b Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 14 Jun 2021 12:51:13 +0000 Subject: [PATCH] Bug 28561: Fix noisy warning about $direction too Use of uninitialized value $direction in string ne at /usr/share/koha/opac/opac-shelves.pl line 265. Bonus: Use of uninitialized value $sortfield in string eq at /usr/share/koha/opac/opac-shelves.pl line 264. Test plan: While testing patch 1, check the logs for these warnings with and without this patch. Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit 3a4dafb754a64c4cda743b3bb72b71cdaa294395) Signed-off-by: Fridolin Somers --- opac/opac-shelves.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index 0ec193c9ec..8b4c801059 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -263,8 +263,8 @@ if ( $op eq 'view' ) { $sortfield = $shelf->sortfield; $direction = 'asc'; } - $sortfield = 'title' unless grep $_ eq $sortfield, qw( title author copyrightdate itemcallnumber dateadded ); - $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc'; + $sortfield = 'title' if !$sortfield or !grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded ); + $direction = 'asc' if !$direction or ( $direction ne 'asc' and $direction ne 'desc' ); my ( $page, $rows ); unless ( $query->param('print') or $query->param('rss') ) { $rows = C4::Context->preference('OPACnumSearchResults') || 20; -- 2.39.5