Bug 39148: Correct sort by publicationdate in OPAC lists

Test plan (UNIMARC):
1 - Create a list with different publicationdates, chose to sort it by
  copyright gate
2 - Go to the list in the OPAC -> it is not correctly sorted
3 - Pick sort order: copyright date -> not correctly sorted
4 - Apply patch
5 - Retry 2&3 and see it works

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Baptiste Wojtkowski 2025-02-17 17:05:55 +01:00 committed by Katrin Fischer
parent cef1685925
commit e398743e06
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 6 additions and 0 deletions

View File

@ -155,6 +155,9 @@ if ( $op eq 'add_form' ) {
$op = $referer;
my $sortfield = $query->param('sortfield');
$sortfield = 'title' unless grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded );
if ( $sortfield eq 'copyrightdate' and C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
$sortfield = 'publicationyear';
}
if ( $shelf->can_be_managed($loggedinuser) ) {
$shelf->shelfname( scalar $query->param('shelfname') );
$shelf->sortfield($sortfield);
@ -328,6 +331,9 @@ if ( $op eq 'view' ) {
$sortfield = 'title'
if !$sortfield
or !grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded );
if ( $sortfield eq 'copyrightdate' and C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
$sortfield = 'publicationyear';
}
my $rows;
if ( $query->param('print') or $query->param('rss') ) {