From: erickson Date: Wed, 6 Oct 2010 15:01:38 +0000 (+0000) Subject: avoid retreiving/searching a linked object, when there is no object to retrieve ... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f9fe5b6a07acf007a4f279205ed799bcdc8071c9;p=evergreen%2Fbjwebb.git 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/trunk@18205 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm index 154bce9c0..1e534b597 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) {