From c4b78a3a7f70b6d8237fedd99a35d49c1196fb8a Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 7 Jan 2026 14:23:55 +0000 Subject: [PATCH] Bug 41237: (QA follow-up): Utilize available logged in user object Content-Type: text/plain; charset=utf-8 Instead of re-fetching the patron object. This also adjusts tests: prove t/db_dependent/Koha/ILL/Requests.t Signed-off-by: Marcel de Rooy --- Koha/ILL/Request.pm | 5 ++--- opac/opac-illrequests.pl | 2 +- t/db_dependent/Koha/ILL/Requests.t | 11 +++++------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index b71fc6db42..4a1c45d255 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -1075,13 +1075,12 @@ pass it $params, as it does not yet have any other data associated with it. =cut sub backend_create { - my ( $self, $params ) = @_; + my ( $self, $params, $loggedin_patron ) = @_; # Establish whether we need to do a generic copyright clearance. if ( $params->{opac} ) { - my $patron = $params->{cardnumber} ? Koha::Patrons->find( { cardnumber => $params->{cardnumber} } ) : undef; - my $patron_branchcode = $patron ? $patron->branchcode : undef; + my $patron_branchcode = $loggedin_patron ? $loggedin_patron->branchcode : undef; my $copyright_content = Koha::AdditionalContents->search_for_display( { category => 'html_customizations', diff --git a/opac/opac-illrequests.pl b/opac/opac-illrequests.pl index 13bece2c5a..cc97f51c9d 100755 --- a/opac/opac-illrequests.pl +++ b/opac/opac-illrequests.pl @@ -186,7 +186,7 @@ if ( $op eq 'list' ) { $params->{cardnumber} = $patron->cardnumber if $patron; $params->{opac} = 1; $params->{lang} = C4::Languages::getlanguage($query); - my $backend_result = $request->backend_create($params); + my $backend_result = $request->backend_create( $params, $patron ); if ( $backend_result->{stage} eq 'copyrightclearance' ) { $template->param( diff --git a/t/db_dependent/Koha/ILL/Requests.t b/t/db_dependent/Koha/ILL/Requests.t index 1dfef65473..d31ffb04d4 100755 --- a/t/db_dependent/Koha/ILL/Requests.t +++ b/t/db_dependent/Koha/ILL/Requests.t @@ -1055,24 +1055,23 @@ subtest 'Backend core methods' => sub { is( $copyright_content->count, 1 ); $backend_create_result = - $illrq->backend_create( - { opac => 1, branchcode => $illrq->patron->branchcode, cardnumber => $illrq->patron->cardnumber } ); + $illrq->backend_create( { opac => 1, branchcode => $illrq->patron->branchcode }, $illrq->patron ); is( $backend_create_result->{stage}, 'copyrightclearance', - 'Additional contents found for provided cardnumber\'s library, should be copyrightclearance stage' + 'Additional contents found for logged in user\'s library, should be copyrightclearance stage' ); $backend_create_result = $illrq->backend_create( { opac => 1, branchcode => $illrq->patron->branchcode } ); is( $backend_create_result->{stage}, 'commit', - 'Cardnumber not supplied and couldnt find additional_contents for all libraries. Dont show copyrightclearance' + 'Logged in patron not supplied and could not find additional_contents for all libraries. Dont show copyrightclearance' ); my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); $backend_create_result = $illrq->backend_create( { opac => 1, branchcode => $patron_1->branchcode } ); is( $backend_create_result->{stage}, 'commit', - 'Supplied cardnumber\'s branchcode doesnt match any additional_contents of same branchcode. Dont show copyrightclearance' + 'Logged in user\'s branchcode does not match any additional_contents of same branchcode. Dont show copyrightclearance' ); my $all_libraries_copyright_content = Koha::AdditionalContents->search_for_display( @@ -1109,7 +1108,7 @@ subtest 'Backend core methods' => sub { $backend_create_result = $illrq->backend_create( { opac => 1, branchcode => $illrq->patron->branchcode } ); is( $backend_create_result->{stage}, 'copyrightclearance', - 'Cardnumber not supplied, found additional_contents for all libraries. Should show copyrightclearance' + 'Logged in user not supplied, found additional_contents for all libraries. Should show copyrightclearance' ); $all_libraries_copyright_content = Koha::AdditionalContents->search_for_display( -- 2.39.5