Bug 27580: Handle NULL values correctly in Koha::Items->filter_by_visible_in_opac
authorTomas Cohen Arazi <tomascohen@theke.io>
Fri, 29 Jan 2021 19:43:06 +0000 (16:43 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 1 Feb 2021 15:15:24 +0000 (16:15 +0100)
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 <tomascohen@theke.io>
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/Items.pm

index 6d401d8..2d81a24 100644 (file)
@@ -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 );