From eed750ba95de3aa7dffce0a73073099d40c40a2e Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 9 Aug 2021 13:41:45 +0000 Subject: [PATCH] Bug 28764: (QA follow-up) Add comment, remove two defined's If we no longer offer the sortfield with :asc actively, we should probably write it somewhere too. Replaced a few defined tests by empty test. No need to split empty string or zero etc. Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- opac/opac-shelves.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index 60796eabcf..d69c173053 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -256,16 +256,19 @@ if ( $op eq 'view' ) { if ( $shelf ) { if ( $shelf->can_be_viewed( $loggedinuser ) ) { $category = $shelf->category; + + # Sortfield param may still include sort order with :asc or :desc, but direction overrides it my( $sortfield, $direction ); - if( defined( $query->param('sortfield') ) ){ # Passed in sorting overrides default sorting + if( $query->param('sortfield') ){ ( $sortfield, $direction ) = split /:/, $query->param('sortfield'); } else { $sortfield = $shelf->sortfield; $direction = 'asc'; } - if( defined( $query->param('direction') ) ){ $direction = $query->param('direction'); } - $sortfield = 'title' if !$sortfield or !grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded ); + $direction = $query->param('direction') if $query->param('direction'); $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 ); unless ( $query->param('print') or $query->param('rss') ) { $rows = C4::Context->preference('OPACnumSearchResults') || 20; -- 2.39.5