From f6444e0bede64e584663a58c9fe3120ac84f170b Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sun, 29 Mar 2015 20:19:16 -0400 Subject: [PATCH] A little defensive programming parsing oils_ncip.xml. If one leaves the block alone, one gets the following Perl error: Can't use string as a HASH ref while "strict refs" in use at /home/opensrf/NCIPServer/lib/NCIP/ILS/Evergreen.pm line 2626. This commit attempts to avoid that. Signed-off-by: Jason Stephenson --- lib/NCIP/ILS/Evergreen.pm | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/NCIP/ILS/Evergreen.pm b/lib/NCIP/ILS/Evergreen.pm index b65490a..d1c957b 100644 --- a/lib/NCIP/ILS/Evergreen.pm +++ b/lib/NCIP/ILS/Evergreen.pm @@ -2623,24 +2623,27 @@ sub _init { # Load the barred groups as pgt objects into a blocked_profiles # list. $self->{blocked_profiles} = []; - foreach (@{$self->{config}->{patrons}->{block_profile}}) { - my $pgt; - if (ref $_) { - $pgt = $U->simplereq( - 'open-ils.pcrud', - 'open-ils.pcrud.retrieve.pgt', - $self->{session}->{authtoken}, - $_->{grp} - ); - } else { - $pgt = $U->simplereq( - 'open-ils.pcrud', - 'open-ils.pcrud.search.pgt', - $self->{session}->{authtoken}, - {name => $_} - ); + if (ref($self->{config}->{patrons}) eq 'HASH') { + foreach (@{$self->{config}->{patrons}->{block_profile}}) { + my $pgt; + if (ref $_) { + $pgt = $U->simplereq( + 'open-ils.pcrud', + 'open-ils.pcrud.retrieve.pgt', + $self->{session}->{authtoken}, + $_->{grp} + ); + } else { + $pgt = $U->simplereq( + 'open-ils.pcrud', + 'open-ils.pcrud.search.pgt', + $self->{session}->{authtoken}, + { + name => $_} + ); + } + push(@{$self->{blocked_profiles}}, $pgt) if ($pgt); } - push(@{$self->{blocked_profiles}}, $pgt) if ($pgt); } # Load the bib source if we're not using precats. -- 2.43.2