From 189d4344f1e242e6ad458d4d3e23997b3e68c1aa 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. Signed-off-by: David Nind Signed-off-by: Lin Wei Li --- 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 b8f7fb55d14..0483438c759 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