[open-ils-commits] r16600 - in trunk/Open-ILS/src/perlmods/OpenILS: . SIP (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Jun 4 16:53:32 EDT 2010


Author: erickson
Date: 2010-06-04 16:53:27 -0400 (Fri, 04 Jun 2010)
New Revision: 16600

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/SIP.pm
   trunk/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm
   trunk/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm
Log:
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.

Modified: trunk/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm	2010-06-04 20:53:25 UTC (rev 16599)
+++ trunk/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm	2010-06-04 20:53:27 UTC (rev 16600)
@@ -128,15 +128,19 @@
 
     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 @@
 
     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 {
     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 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';
 }

Modified: trunk/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm	2010-06-04 20:53:25 UTC (rev 16599)
+++ trunk/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm	2010-06-04 20:53:27 UTC (rev 16600)
@@ -121,13 +121,20 @@
 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 {

Modified: trunk/Open-ILS/src/perlmods/OpenILS/SIP.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/SIP.pm	2010-06-04 20:53:25 UTC (rev 16599)
+++ trunk/Open-ILS/src/perlmods/OpenILS/SIP.pm	2010-06-04 20:53:27 UTC (rev 16600)
@@ -583,7 +583,7 @@
 
 	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.");
 		}



More information about the open-ils-commits mailing list