Use just one transaction, and inside an rstore editor no less, for fleshing env paths
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 13 Oct 2010 16:17:14 +0000 (16:17 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 13 Oct 2010 16:17:14 +0000 (16:17 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18312 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm

index c6894a6..9043153 100644 (file)
@@ -481,11 +481,16 @@ sub _object_by_path {
     my $collector = shift;
     my $label = shift;
     my $path = shift;
+    my $ed = shift;
 
+    my $outer = 0;
+    if (!$ed) {
+        $ed = new_rstore_editor(xact=>1);
+        $outer = 1;
+    }
 
     my $step = shift(@$path);
 
-
     my $fhint = Fieldmapper->publish_fieldmapper->{$context->class_name}{links}{$step}{class};
     my $fclass = $self->_fm_class_by_hint( $fhint );
 
@@ -509,10 +514,6 @@ sub _object_by_path {
     $meth =~ s/Fieldmapper:://;
     $meth =~ s/::/_/g;
 
-    my $ed = grep( /open-ils.cstore/, @{$fclass->Controller} ) ?
-            $self->editor :
-            new_rstore_editor(($self->standalone ? () : (xact=>1)));
-
     my $obj = $context->$step(); 
 
     $logger->debug(
@@ -529,18 +530,10 @@ sub _object_by_path {
             my $def_id = $self->event->event_def->id;
             my $str_path = join('.', @$path);
 
-            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;
-            }
         }
     }
 
@@ -555,7 +548,7 @@ sub _object_by_path {
 
         for (@$obj_list) {
             my @path_clone = @$path;
-            $self->_object_by_path( $_, $collector, $label, \@path_clone );
+            $self->_object_by_path( $_, $collector, $label, \@path_clone, $ed );
         }
 
         $obj = $$obj_list[0] if (!$multi || $rtype eq 'might_have');
@@ -598,6 +591,7 @@ sub _object_by_path {
         }
     }
 
+    $ed->rollback if ($outer);
     return $obj;
 }