From d40a884dad40a9452d74f4606e6e47c4dce79bd3 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 6 Oct 2010 15:03:36 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_2_0@18206 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Trigger/Event.pm | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm index 154bce9c02..1e534b597f 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm @@ -514,23 +514,26 @@ sub _object_by_path { 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) { -- 2.11.0