[open-ils-commits] r18206 - branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Oct 6 11:03:38 EDT 2010


Author: erickson
Date: 2010-10-06 11:03:36 -0400 (Wed, 06 Oct 2010)
New Revision: 18206

Modified:
   branches/rel_2_0/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: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm	2010-10-06 15:01:38 UTC (rev 18205)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm	2010-10-06 15:03:36 UTC (rev 18206)
@@ -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