From 1a15002bfaf79d96b8a4925e44fa1f8813c82276 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 23 Jul 2024 12:14:44 +0000 Subject: [PATCH] Bug 37378: libraries_where_can_see_things should always return an array The subroutine libraries_where_can_see_things stores the list of libraries that things can be viewed from in an internal variable, so we can return this directly if we have already calculated. When returning if not cached, we dereference the list and return an array. If cached, we are returning an arrayref. This patch simply ensures we dereference the array even if already cached. Before this patch, we were fetching the patrons, then redacting all info as their branches didn't match against an arrayref, rather than checking against each branch we are allowed to view. To test: 1. Setup a library group and check the "Limit patron data access by group ." option. 2. Add some libraries to the group. ( IN k-t-d I added CPL and MPL ) 3. Create a staff account who has staff access permissions and all of the borrower permissions except "view_borrower_infos_from_any_libraries" 4. Set the home library of that staff member to one of the branches in step 2. ( In my test I choose MPL ) 5. Log in as that patron and attempt a patron search that would include users from either library in step 2. 6. See the error: Something went wrong when loading the table. 500: Internal Server Error. Expected boolean - got null. Expected boolean - got null. Expected string - got null. Expected string - got null. Expected string - got null. Expected integer - got null. Expected integer - got null. Expected integer - got null. Expected boolean - got null. Expected boolean - got null. Expected string - got null. 7. Apply patch, restart all 8. Search again, you can see the expected patrons Signed-off-by: Brendan Lawlor Signed-off-by: Martin Renvoize (cherry picked from commit ebdf121a7de99e7cfaf53d5177621b9cbca7338c) Signed-off-by: Lucas Gass (cherry picked from commit 7ec7fc7ce0af941d53529dd35a5150155521c1c8) Signed-off-by: Fridolin Somers --- Koha/Patron.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 0cf8240460..3971943ce2 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1919,7 +1919,7 @@ sub libraries_where_can_see_things { my $subpermission = $params->{subpermission}; my $group_feature = $params->{group_feature}; - return $self->{"_restricted_branchcodes:$permission:$subpermission:$group_feature"} + return @{ $self->{"_restricted_branchcodes:$permission:$subpermission:$group_feature"} } if exists( $self->{"_restricted_branchcodes:$permission:$subpermission:$group_feature"} ); my $userenv = C4::Context->userenv; -- 2.39.5