From b60ff6452ef2212a02f16ddc5c46edeb3d83a5e3 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 29 Jan 2021 16:43:06 -0300 Subject: [PATCH] Bug 27580: Handle NULL values correctly in Koha::Items->filter_by_visible_in_opac This patch fixes the internally used query so it doesn't consider NULL values as IN the set. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Items.t => FAIL: Tests fail :-/ 3. Apply this patch 4. Repeat 2 => SUCCESS: tests pass! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- Koha/Items.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Koha/Items.pm b/Koha/Items.pm index 6d401d83ef..2d81a24c59 100644 --- a/Koha/Items.pm +++ b/Koha/Items.pm @@ -78,8 +78,9 @@ sub filter_by_visible_in_opac { my $rules = C4::Context->yaml_preference('OpacHiddenItems') // {}; my $rules_params; - foreach my $field (keys %$rules){ - $rules_params->{$field}->{'-not_in'} = $rules->{$field}; + foreach my $field ( keys %$rules ) { + $rules_params->{$field} = + [ { '-not_in' => $rules->{$field} }, undef ]; } $result = $result->search( $rules_params ); -- 2.39.5