From f33e3d99bac59becd782fce2190362773833df68 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 12 May 2025 13:30:12 +0000 Subject: [PATCH] Bug 39875: Dont show history check Unless there is a cardnumber or an authenticated user Test plan: 1) Apply only the the tests file highlighting the issue: prove t/db_dependent/Koha/ILL/Request/Workflow/HistoryCheck.t 2) Notice it fails. 3) Apply this patch. 4) Run tests again. Notice it passes. --- Koha/ILL/Request/Workflow/HistoryCheck.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Koha/ILL/Request/Workflow/HistoryCheck.pm b/Koha/ILL/Request/Workflow/HistoryCheck.pm index b8f7fb55d14..0c01c59bbbf 100644 --- a/Koha/ILL/Request/Workflow/HistoryCheck.pm +++ b/Koha/ILL/Request/Workflow/HistoryCheck.pm @@ -193,9 +193,10 @@ sub _find_matching_requests { @existing_id_fields = grep { $_ eq 'pubmedid' } @existing_id_fields; } - my $patron = Koha::Patrons->find( - { cardnumber => $self->{metadata}->{cardnumber} || C4::Context->userenv->{'cardnumber'} } ); + my $cardnumber = $self->{metadata}->{cardnumber} || ( C4::Context->userenv && C4::Context->userenv->{'cardnumber'} ); + return 0 unless $cardnumber; + my $patron = Koha::Patrons->find( { cardnumber => $cardnumber} ); return 0 unless $patron; my $query; -- 2.39.5