From cd1dbe4894fe54bf926419d6e119488da2b2388a Mon Sep 17 00:00:00 2001 From: Baptiste Date: Mon, 9 Mar 2026 15:43:10 +0100 Subject: [PATCH] Bug 42011: Fix checkouts search in readingrec.pl Test plan: 1 - Run perl script provided hereafter 2 - Apply first patch. Notice there is a lot of checkouts 3 - Apply second patch, notice you can see only 2 searches Script: use C4::Circulation qw( AddIssue AddReturn ); use Koha::Items; use Koha::Patrons; use t::lib::Mocks; use Koha::DateUtils qw(dt_from_string); my $patron = Koha::Patrons->find(51); t::lib::Mocks::mock_userenv({patron => $patron}); my $items = Koha::Items->search; my $patron_unblessed = $patron->unblessed; my $i = 0; my $item = $items->next ; while ( 1 ) { my $due = dt_from_string->subtract(days => 45 + rand(45))->set_hour(23)->set_minute(59)->set_second(00); AddIssue($patron, $item->barcode, $due); last if ++$i >= 10; AddReturn($item->barcode, 'CPL'); } --- members/readingrec.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/members/readingrec.pl b/members/readingrec.pl index 6cbb2672c56..d403745f544 100755 --- a/members/readingrec.pl +++ b/members/readingrec.pl @@ -91,10 +91,10 @@ if ( $patron->is_anonymous ) { } else { $template->param( checkouts => [ - $patron->checkouts( + $patron->checkouts->search( {}, { - order_by => 'date_due desc', + order_by => { -desc => 'date_due' }, prefetch => { item => { biblio => 'biblioitems' } }, rows => 1, } @@ -103,10 +103,10 @@ if ( $patron->is_anonymous ) { ); $template->param( old_checkouts => [ - $patron->old_checkouts( + $patron->old_checkouts->search( {}, { - order_by => 'date_due desc', + order_by => { -desc => 'date_due' }, prefetch => { item => { biblio => 'biblioitems' } }, rows => 1, } -- 2.30.2