From 9c320cd5ac7768f75e2077deff8e4d78137acd87 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 --- 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 167c7648c9..6796691f1f 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -260,16 +260,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