Bug 25142: Fix wrong grep logical test

To test and understand what's going on, you can try that bit of code:
my @a = qw( a b c a);
my @b = qw( b c d );
my @c;
@c = grep { 'a' eq $_ } @a ? 'ok' : ();
say @c;
@c = ( grep { 'a' eq $_ } @a ) ? 'ok' : ();
say @c;
@c = grep { 'a' eq $_ } @a ? ('ok') : (undef);
say @c;

The problem here:
Have patrons in 3 branches CPL, MPL, SPL
Have a non superlibrarian with edit_borrowers permission but
without view_borrower_infos_from_any_libraries, from CPL
Create a library group with CPL, MPL
Use that non superlibrarian to search for patrons
You can search for patrons fro CPL and MPL
BUT, edit the value for CPL, use SPL (edit the DOM)
Search and... oops

Apply this patch, try again

Also use a superlibrarian patron (and/or with view_borrower_infos_from_any_libraries)
and confirm that they can see all patrons

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Tested with edit_borrowers permission but NOT view_borrower_infos_from_any_libraries
Editing the DOM I can search (not edit) from any branch
With patch no entries found :)

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Amended test plan slightly (+ without)

Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
(cherry picked from commit c33f598c5c)

Signed-off-by: Hayley Mapley <hayleymapley@catalyst.net.nz>
This commit is contained in:
Jonathan Druart 2020-04-14 13:22:44 +02:00 committed by Hayley Mapley
parent 3b8c2467e5
commit dfe1bd600c
1 changed files with 1 additions and 1 deletions

View File

@ -38,7 +38,7 @@ sub search {
# Do that after iTotalQuery!
if ( defined $branchcode and $branchcode ) {
@restricted_branchcodes = @restricted_branchcodes
? grep { /^$branchcode$/ } @restricted_branchcodes
? ( grep { /^$branchcode$/ } @restricted_branchcodes )
? ($branchcode)
: (undef) # Do not return any results
: ($branchcode);