From eb358bf48fd50e680c8f1abe93f1528a0acfe7bd Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 17 Nov 2021 14:30:21 -0300 Subject: [PATCH] Bug 29506: Make objects.search call search_limited if present This patch makes objects.search implicitly update the passed *$result_set* to use search_limited. This way no object leaks could happen without noticing. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/REST/Plugin/Objects.t => FAIL: Tests fail because search_limited is not used 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! Results are correctly filtered based on userenv! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens Signed-off-by: Andrew Fuerste-Henry --- Koha/REST/Plugin/Objects.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm index 7ccc1c4cf4..69b53e5d8a 100644 --- a/Koha/REST/Plugin/Objects.pm +++ b/Koha/REST/Plugin/Objects.pm @@ -150,6 +150,11 @@ for API rendering. $filtered_params = $c->merge_q_params( $filtered_params, $query_params, $result_set ); } + + # If search_limited exists, use it + $result_set = $result_set->search_limited, + if $result_set->can('search_limited'); + # Perform search my $objects = $result_set->search( $filtered_params, $attributes ); my $total = $result_set->search->count; -- 2.39.5