[open-ils-commits] r18205 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Oct 6 11:01:40 EDT 2010


Author: erickson
Date: 2010-10-06 11:01:38 -0400 (Wed, 06 Oct 2010)
New Revision: 18205

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
Log:
avoid retreiving/searching a linked object, when there is no object to retrieve (i.e. ident value is null) and silence various warnings by skipping this scenario.  mild variable refactor for easy reading for feeble eyes.

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm	2010-10-06 15:01:12 UTC (rev 18204)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm	2010-10-06 15:01:38 UTC (rev 18205)
@@ -514,23 +514,26 @@
 
     if (!ref $obj) {
 
-        if ($self->standalone) {
-            $ed->xact_begin || return undef;
-        }
+        my $lval = $context->$lfield();
 
-        $obj = $_object_by_path_cache{$self->event->event_def->id}{join('.',@$path)}{$step}{$ffield}{$context->$lfield()} ||
-            $ed->$meth( 
-                ($multi) ?
-                    { $ffield => $context->$lfield() } :
-                    $context->$lfield()
-            );
+        if(defined $lval) {
 
-        $_object_by_path_cache{$self->event->event_def->id}{join('.',@$path)}{$step}{$ffield}{$context->$lfield()} ||= $obj;
+            my $def_id = $self->event->event_def->id;
+            my $str_path = join('.', @$path);
 
-        if ($self->standalone) {
-            $ed->xact_rollback || return undef;
+            if ($self->standalone) {
+                $ed->xact_begin || return undef;
+            }
+
+            $obj = $_object_by_path_cache{$def_id}{$str_path}{$step}{$ffield}{$lval} ||
+                $ed->$meth( ($multi) ? { $ffield => $lval } : $lval);
+
+            $_object_by_path_cache{$def_id}{$str_path}{$step}{$ffield}{$lval} ||= $obj;
+
+            if ($self->standalone) {
+                $ed->xact_rollback || return undef;
+            }
         }
-
     }
 
     if (@$path) {



More information about the open-ils-commits mailing list