From 19708b2069d5702114288fe90f28493756aebe9a Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Thu, 19 Feb 2009 10:20:07 -0600 Subject: [PATCH] Bug 2968 - SIP ACS_STATUS message (98) misreported config. The *_ok methods in ILS.pm were targeting the wrong depth. This also resolves a longstanding FIXME on to_bool() warning like: Argument "\x{66}\x{61}..." isn't numeric in numeric ne (!=) at /ILS.pm line 94. The example_institution_dump.sh essentially provides the proof test case for this patch. Run it before/after on SIPconfig.xml where "MAIN" has checkout="true" and checkin="true". --- C4/SIP/ILS.pm | 25 +++++++++++-------------- C4/SIP/example_institution_dump.sh | 15 ++++++++++++++- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/C4/SIP/ILS.pm b/C4/SIP/ILS.pm index 1a4fc542b9..f99911229d 100644 --- a/C4/SIP/ILS.pm +++ b/C4/SIP/ILS.pm @@ -86,33 +86,30 @@ sub to_bool { my $bool = shift; # If it's defined, and matches a true sort of string, or is # a non-zero number, then it's true. - # - # FIXME: this test is faulty - # We're running under warnings and strict. - # But if we don't match regexp, then we go ahead and numerical compare? - # That means we'd generate a warning on 'FALSE' or ''. - return defined($bool) && (($bool =~ /true|y|yes/i) || $bool != 0); + defined($bool) or return; # false + ($bool =~ /true|y|yes/i) and return 1; # true + return ($bool =~ /^\d+$/ and $bool != 0); # true for non-zero numbers, false otherwise } sub checkout_ok { my $self = shift; - return (exists($self->{policy}->{checkout}) - && to_bool($self->{policy}->{checkout})); + return (exists($self->{institution}->{policy}->{checkout}) + && to_bool($self->{institution}->{policy}->{checkout})); } sub checkin_ok { my $self = shift; - return (exists($self->{policy}->{checkin}) - && to_bool($self->{policy}->{checkin})); + return (exists($self->{institution}->{policy}->{checkin}) + && to_bool($self->{institution}->{policy}->{checkin})); } sub status_update_ok { my $self = shift; - return (exists($self->{policy}->{status_update}) - && to_bool($self->{policy}->{status_update})); + return (exists($self->{institution}->{policy}->{status_update}) + && to_bool($self->{institution}->{policy}->{status_update})); } sub offline_ok { my $self = shift; - return (exists($self->{policy}->{offline}) - && to_bool($self->{policy}->{offline})); + return (exists($self->{institution}->{policy}->{offline}) + && to_bool($self->{institution}->{policy}->{offline})); } # diff --git a/C4/SIP/example_institution_dump.sh b/C4/SIP/example_institution_dump.sh index 3aa32f3d42..3837e754e7 100755 --- a/C4/SIP/example_institution_dump.sh +++ b/C4/SIP/example_institution_dump.sh @@ -1,3 +1,16 @@ #!/bin/bash -perl -I ./ -e 'use Data::Dumper; use ILS; use Sip::Configuration; $conf=Sip::Configuration->new("SIPconfig.xml"); print Dumper($conf->{institutions}->{"MAIN"}),"\n";' +perl -I ./ -e ' +use Data::Dumper; +use ILS; +use Sip::Configuration; +my $code = "MAIN"; +my $conf = Sip::Configuration->new("SIPconfig.xml"); +my $ils = ILS->new($conf->{institutions}->{$code}); +print "XML for $code: ", Dumper($conf->{institutions}->{$code}), "\n"; +print "ILS for $code: ", Dumper($ils), "\n"; +print "\$ils->checkout_ok(): ", ($ils->checkout_ok() ? "Y" : "N"), "\n"; +print "\$ils->checkin_ok() : ", ($ils->checkin_ok() ? "Y" : "N"), "\n"; +print "\$ils->offline_ok() : ", ($ils->offline_ok() ? "Y" : "N"), "\n"; +print "\n"; +' -- 2.39.5