Bug 16198: Fix regression in OPAC suggestions

Introduced by
  commit d564d3732d
  Bug 15629: Koha::Libraries - Remove GetBranchInfo

If the branchcodesuggestedby is not defined, the find won't return
anything and ->branchname on an undefined value will raise
  Can't call method "branchname" on an undefined value at
  /home/katrin/kohaclone/opac/opac-suggestions.pl line 153.

Test plan:
-Staff
Create a patron
Use this patron to create a suggestion
Delete the patron

-OPAC
Logout and trigger opac/opac-suggestions.pl

Without this patch, you will get an error
With this patch applied, everything should be ok

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Works ok following test plan
No errors

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2016-04-05 08:27:46 +01:00 committed by Brendan A Gallagher
parent 22a33b7868
commit 833afc1245
1 changed files with 6 additions and 1 deletions

View File

@ -150,7 +150,12 @@ if ( $op eq "delete_confirm" ) {
print $input->redirect("/cgi-bin/koha/opac-suggestions.pl?op=else");
exit;
}
map{ $_->{'branchcodesuggestedby'} = Koha::Libraries->find($_->{'branchcodesuggestedby'})->branchname} @$suggestions_loop;
map{
my $s = $_;
my $library = Koha::Libraries->find($s->{branchcodesuggestedby});
$library ? $s->{branchcodesuggestedby} = $library->branchname : ()
} @$suggestions_loop;
foreach my $suggestion(@$suggestions_loop) {
if($suggestion->{'suggestedby'} == $borrowernumber) {