From 7db7003c6a34acd408b34049bb50be06e4d82aad 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 Content-Type: text/plain; charset=utf-8 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. Signed-off-by: David Nind Signed-off-by: Lin Wei Li Signed-off-by: Marcel de Rooy --- Koha/ILL/Request/Workflow/HistoryCheck.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Koha/ILL/Request/Workflow/HistoryCheck.pm b/Koha/ILL/Request/Workflow/HistoryCheck.pm index b8f7fb55d1..0483438c75 100644 --- a/Koha/ILL/Request/Workflow/HistoryCheck.pm +++ b/Koha/ILL/Request/Workflow/HistoryCheck.pm @@ -193,9 +193,11 @@ 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