From de1dcadba6c6a061ea3e2c0bcf257813cc72dea2 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 17 Apr 2025 13:05:16 +0000 Subject: [PATCH] Bug 38441: (QA follow-up): Only look for matchin requests if patron Previous commit 'HistoryCheck now only considers same patron' added the following regression: HistoryCheck is performed and shown in the OPAC even if no user is authenticated (using ILLOpacUnauthenticatedRequest). This fixes that. History check is skipped unless a user exists. --- Koha/ILL/Request/Workflow/HistoryCheck.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Koha/ILL/Request/Workflow/HistoryCheck.pm b/Koha/ILL/Request/Workflow/HistoryCheck.pm index 5a3eefbddf4..818f2f4c742 100644 --- a/Koha/ILL/Request/Workflow/HistoryCheck.pm +++ b/Koha/ILL/Request/Workflow/HistoryCheck.pm @@ -195,8 +195,10 @@ sub _find_matching_requests { my $patron = Koha::Patrons->find( { cardnumber => $self->{metadata}->{cardnumber} } ); + return 0 unless $patron; + my $query; - $query->{'-and'} = [ { 'me.borrowernumber' => $patron->borrowernumber } ] if $patron; + $query->{'-and'} = [ { 'me.borrowernumber' => $patron->borrowernumber } ]; foreach my $id_field (@existing_id_fields) { push @{ $query->{'-or'} }, { 'illrequestattributes.type' => $id_field, -- 2.39.5