back-porting action trigger fixes 16956 and 16953
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 16 Jul 2010 14:12:44 +0000 (14:12 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 16 Jul 2010 14:12:44 +0000 (14:12 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6_1@16958 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
Open-ILS/src/support-scripts/action_trigger_runner.pl

index c5d38bd..f4c64d9 100644 (file)
@@ -409,16 +409,14 @@ sub create_batch_events {
             push @{ $$filter{'-and'} }, $f;
         }
 
-        push @{ $filter->{'-and'} }, {
-            '-not-exists' => {
-                from  => 'atev',
-                where => {
-                    event_def => $def->id,
-                    target    => { '=' => { '+' . $hook_hash{$def->hook}->core_type => $class->Identity } },
-                    ($active ? (state  => 'pending') : ())
-                }
+        my $join = { 'join' => {
+            atev => {
+                field => 'target',
+                fkey => $class->Identity,
+                type => 'left',
+                filter => { event_def => $def->id }
             }
-        };
+        }};
 
         $class =~ s/^Fieldmapper:://o;
         $class =~ s/::/_/go;
@@ -430,7 +428,7 @@ sub create_batch_events {
 
         $logger->info("trigger: create_batch_events() collecting object IDs for def=$def_id / hook=$hook");
 
-        my $object_ids = $editor->$method( $filter, {idlist => 1, timeout => 10800} );
+        my $object_ids = $editor->$method( [$filter, $join], {idlist => 1, timeout => 10800} );
 
         if($object_ids) {
             $logger->info("trigger: create_batch_events() fetched ".scalar(@$object_ids)." object IDs for def=$def_id / hook=$hook");
index 40eae8f..2fb5518 100755 (executable)
@@ -174,7 +174,10 @@ help() and exit unless ($opt_run_pending or $opt_process_hooks);
 if (-e $opt_lockfile) {
     die "I'm already running with lockfile $opt_lockfile\n" if (!$opt_process_hooks);
     # sleeping loop if we're in --process-hooks mode
-    do { last unless ( -e $opt_lockfile ); $max_sleep--; } while ($max_sleep >= 0 && sleep(1));
+    while ($max_sleep >= 0 && sleep(1)) {
+        last unless ( -e $opt_lockfile ); 
+        $max_sleep--;
+    }
 }
 
 # there's a tiny race condition here ... oh well