when the target for an event is no longer around, immediately invalidate the event...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 13 Oct 2010 16:13:23 +0000 (16:13 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 13 Oct 2010 16:13:23 +0000 (16:13 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18311 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index c9c1553..ae83a77 100644 (file)
@@ -644,7 +644,7 @@ sub gather_events {
             $logger->error("trigger: Event creation failed with ".shift());
         };
 
-        next unless $e; 
+        next if !$e or $e->event->state eq 'invalid'; 
 
         try {
             $e->build_environment;
@@ -717,9 +717,16 @@ sub grouped_events {
             my @steps = split /\./, $group;
             my $group_field = pop(@steps); # we didn't flesh to this, it's a field not an object
 
-            # find the grouping object
-            my $node = $e->target;
-            $node = $node->$_() for ( @steps );
+            my $node;
+            eval {
+                $node = $e->target;
+                $node = $node->$_() for ( @steps );
+            };
+
+            unless($node) { # should not get here, but to be safe..
+                $e->update_state('invalid');
+                next;
+            }
 
             # get the grouping value for the grouping object on this event
             my $ident_value = $node->$group_field();
index 1a19895..c6894a6 100644 (file)
@@ -112,6 +112,11 @@ sub init {
         $self->editor->xact_rollback || return undef;
     }
 
+    unless($self->target) {
+        $self->update_state('invalid');
+        $self->valid(0);
+    }
+
     return $self;
 }