From: erickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Fri, 4 Jun 2010 20:53:27 +0000 (+0000) Subject: Bugfixes: undef handling and legacy script support setting. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=019ec31c84ed68ea1006d748845b8166691158ae;p=contrib%2FConifer.git Bugfixes: undef handling and legacy script support setting. The legacy setting was a major bug. It was not possible to disable legacy scripts except by *removing* the setting. That is, if you set it to 'false', we failed to interpret that here in SIP to mean FALSE. Instead we looked at it as a non-zero-length string and therefore TRUE! This patch also prevents warnings from unitialized values (undef concatenation), like: Use of uninitialized value in concatenation (.) or string at /openils/lib/perl5/OpenILS/SIP/Patron.pm line 110. Added a little formatting and whitespace cleanup to address display along w/ undef handling. Corrected an error screen message also. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16600 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/SIP.pm b/Open-ILS/src/perlmods/OpenILS/SIP.pm index b6183d4ee2..a33597336d 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP.pm @@ -583,7 +583,7 @@ sub renew { if(!$trans->item) { if( $title_id ) { - $trans->screen_msg("Item Id renewal not supported."); + $trans->screen_msg("Title ID renewal not supported. Use item barcode."); } else { $trans->screen_msg("Invalid item barcode."); } diff --git a/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm b/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm index 9fb84af85e..c2805691a7 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm @@ -128,15 +128,19 @@ sub new { syslog("LOG_DEBUG", "OILS: Item('$item_id'): found with title '%s'", $self->title_id); - my $config = OpenILS::SIP->config(); + my $config = OpenILS::SIP->config(); # FIXME : will not always match! - if( defined $config->{implementation_config}->{legacy_script_support} ) { - $self->{legacy_script_support} = - ($config->{implementation_config}->{legacy_script_support} =~ /true/io); + my $legacy = $config->{implementation_config}->{legacy_script_support} || undef; + if( defined $legacy ) { + $self->{legacy_script_support} = ($legacy =~ /t(rue)?/io) ? 1 : 0; + syslog("LOG_DEBUG", "legacy_script_support is set in SIP config: " . $self->{legacy_script_support}); } else { - $self->{legacy_script_support} = - OpenSRF::Utils::SettingsClient->new->config_value( - apps => 'open-ils.circ' => app_settings => 'legacy_script_support') + my $lss = OpenSRF::Utils::SettingsClient->new->config_value( + apps => 'open-ils.circ', + app_settings => 'legacy_script_support' + ); + $self->{legacy_script_support} = ($lss =~ /t(rue)?/io) ? 1 : 0; + syslog("LOG_DEBUG", "legacy_script_support is set in SRF config: " . $self->{legacy_script_support}); } return $self; @@ -149,6 +153,7 @@ sub run_attr_script { if($self->{legacy_script_support}){ + syslog('LOG_DEBUG', "Legacy script support is ON"); my $config = OpenILS::SIP->config(); my $path = $config->{implementation_config}->{scripts}->{path}; my $item_config_script = $config->{implementation_config}->{scripts}->{item_config}; @@ -202,7 +207,7 @@ sub magnetic_media { sub magnetic { my $self = shift; return 0 unless $self->run_attr_script; - my $mag = $self->{item_config_result}->{item_config}->{magneticMedia}; + my $mag = $self->{item_config_result}->{item_config}->{magneticMedia} || ''; syslog('LOG_DEBUG', "OILS: magnetic = $mag"); return ($mag and $mag =~ /t(rue)?/io) ? 1 : 0; } @@ -210,7 +215,7 @@ sub magnetic { sub sip_media_type { my $self = shift; return 0 unless $self->run_attr_script; - my $media = $self->{item_config_result}->{item_config}->{SIPMediaType}; + my $media = $self->{item_config_result}->{item_config}->{SIPMediaType} || ''; syslog('LOG_DEBUG', "OILS: media type = $media"); return ($media) ? $media : '001'; } diff --git a/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm index 7d038c5475..63e63e5624 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm @@ -121,13 +121,20 @@ sub home_library { sub __addr_string { my $addr = shift; return "" unless $addr; - return OpenILS::SIP::clean_text($addr->street1 .' '. - $addr->street2 .' '. - $addr->city .' '. - $addr->county .' '. - $addr->state .' '. - $addr->country .' '. - $addr->post_code); + my $return = OpenILS::SIP::clean_text( + join( ' ', map {$_ || ''} ( + $addr->street1, + $addr->street2, + $addr->city . ',', + $addr->county, + $addr->state, + $addr->country, + $addr->post_code + ) + ) + ); + $return =~ s/\s+/ /sg; # Compress any run of of whitespace to one space + return $return; } sub address {