From 0ec5fd4df63bd2d79d7c24b5db3386e57b925289 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 --- 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 ddf2194530..7b843bafbe 100644 --- a/Koha/REST/Plugin/Objects.pm +++ b/Koha/REST/Plugin/Objects.pm @@ -152,6 +152,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.20.1