From 5ecdbcae32cb5ec5b4c80da257d56e25dec865e6 Mon Sep 17 00:00:00 2001 From: Laura_Escamilla Date: Fri, 26 Sep 2025 15:36:40 +0000 Subject: [PATCH] Bug 40886: Ensure patron messages display in proper chronological order 1. Create several random patron circ messages with different dates. I used the following sql for my ktd: -- INSERT INTO messages (borrowernumber, branchcode, message_type, message, message_date) SELECT 51 AS borrowernumber, 'CPL' AS branchcode, ELT(FLOOR(1 + (RAND() * 3)), 'L','B','E') AS message_type, -- L=Staff note, B=OPAC, E=Email (adjust to your codes) CONCAT('Random test message ', FLOOR(RAND()*1000)) AS message, DATE_ADD(CURDATE(), INTERVAL -FLOOR(RAND() * 1825) DAY) AS message_date -- random day in last ~5 years (5*365) FROM ( SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 ) AS x; 2. View the patron account and notice that messages are sorted by type, but not by date. 3. Apply the patch and restart_all 4. Refresh the patron account page and clear the browser cache if necessary. 5. View the patron account again and notice that the messages are still sorted by type, but they are also sorted in descending order (newest to oldest). 6. Sign off and have a great day! Signed-off-by: Jen Tormey Signed-off-by: Lucas Gass (cherry picked from commit 7be401fcbd0d4355c629f03185399f648a94de23) Signed-off-by: Paul Derscheid --- circ/circulation.pl | 2 +- members/moremember.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index d85defd0ad..c5bd16570f 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -739,7 +739,7 @@ if ($patron) { join => 'manager', '+select' => [ 'manager.surname', 'manager.firstname' ], '+as' => [ 'manager_surname', 'manager_firstname' ], - 'order_by' => { -desc => 'me.message_type' }, + 'order_by' => [ 'me.message_type', { -desc => 'me.message_date' }, { -desc => 'me.message_id' } ], } ); $template->param( patron_messages => $patron_messages ); diff --git a/members/moremember.pl b/members/moremember.pl index 4a8d789d1f..ecedd5ac58 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -189,7 +189,7 @@ my $patron_messages = Koha::Patron::Messages->search( join => 'manager', '+select' => [ 'manager.surname', 'manager.firstname' ], '+as' => [ 'manager_surname', 'manager_firstname' ], - 'order_by' => { -desc => 'me.message_type' }, + 'order_by' => [ 'me.message_type', { -desc => 'me.message_date' }, { -desc => 'me.message_id' } ], } );