Fixed cronjobs which seem to have been stuck due to other failing ones
authorAlexander Ebert <ebert@woltlab.com>
Wed, 14 Aug 2013 19:08:07 +0000 (21:08 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 14 Aug 2013 19:08:07 +0000 (21:08 +0200)
wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php
wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php

index ce5b2807a104d95fe869a1220422b0ba958e2b7c..6953a1af288dc601e7f1e8fb6083fc6ef251bbe5 100644 (file)
@@ -108,12 +108,6 @@ class CronjobAction extends AbstractDatabaseObjectAction implements IToggleActio
                $return = array();
                
                foreach ($this->objects as $key => $cronjob) {
-                       // skip jobs that are already being processed
-                       if ($cronjob->state == Cronjob::PENDING || $cronjob->state == Cronjob::EXECUTING) {
-                               unset($this->objects[$key]);
-                               continue;
-                       }
-                       
                        // mark them as pending
                        $cronjob->update(array('state' => Cronjob::PENDING));
                }
index 2f029a2cdbce2539b1f4b84fb202ad70afa3ffc7..d5c7bfeb394886398b7b00571bd271459a478462 100644 (file)
@@ -124,15 +124,17 @@ class CronjobScheduler extends SingletonFactory {
                        );
                        
                        // reset cronjob if it got stuck before and afterNextExec is in the past
-                       if ($cronjobEditor->afterNextExec <= TIME_NOW && $cronjobEditor->state == Cronjob::EXECUTING) {
-                               $failCount = $cronjobEditor->failCount + 1;
-                               $data['failCount'] = $failCount;
-                               
-                               // disable cronjob
-                               if ($failCount == Cronjob::MAX_FAIL_COUNT) {
-                                       $data['isDisabled'] = 1;
-                                       $data['state'] = 0;
-                                       $executeCronjob = false;
+                       if ($cronjobEditor->afterNextExec <= TIME_NOW) {
+                               if ($cronjobEditor->state == Cronjob::EXECUTING) {
+                                       $failCount = $cronjobEditor->failCount + 1;
+                                       $data['failCount'] = $failCount;
+                                       
+                                       // disable cronjob
+                                       if ($failCount == Cronjob::MAX_FAIL_COUNT) {
+                                               $data['isDisabled'] = 1;
+                                               $data['state'] = 0;
+                                               $executeCronjob = false;
+                                       }
                                }
                        }
                        // ignore cronjobs which seem to be running