From fa4189e9ce2fa92a590310afd968179932116ae4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 10 Oct 2025 09:59:53 +0200 Subject: [PATCH] Bug 40324: Prevent 500 when no borrower_debarments for debarred patrons There are reports of crash when viewing patron records that are debarred but does not have a borrower_debarments entry. We should know how those records have been created. It's data inconsistency and I don't think we should deal with that in the code. The DB structure is not really correct: we should not have borrowers.debarred, but we kept it for historical reasons (and reports). This patch fixes the 500, but there are then other problems on the screen: Top of the screen: " Account restricted since " Under the "Restrictions (0)" tab: "Patron is currently unrestricted." --- members/moremember.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/members/moremember.pl b/members/moremember.pl index 9cf8574e101..05dd317fad5 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -86,10 +86,11 @@ for (qw(gonenoaddress lost borrowernotes is_debarred)) { $template->param( restriction_types => scalar Koha::Patron::Restriction::Types->search() ); if ( $patron->is_debarred ) { + my $restriction = $patron->restrictions->search->single; $template->param( 'userdebarred' => $patron->debarred, 'debarredcomment' => $patron->debarredcomment, - 'debarredsince' => $patron->restrictions->search()->single->created, + 'debarredsince' => $restriction ? $restriction->single->created : undef, ); if ( $patron->debarred ne "9999-12-31" ) { -- 2.34.1