From 7df31df4c4db26a6b74e194cfed89c68a27d9b02 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 Content-Type: text/plain; charset=utf-8 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 --- 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.20.1