From 682b28b9bc427220be85c645d9475257f6f9877b Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 13 Oct 2010 16:17:14 +0000 Subject: [PATCH] Use just one transaction, and inside an rstore editor no less, for fleshing env paths git-svn-id: svn://svn.open-ils.org/ILS/trunk@18312 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Trigger/Event.pm | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm index c6894a686..904315375 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm @@ -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; } -- 2.11.0