Fixed cronjob execution
authorAlexander Ebert <ebert@woltlab.com>
Wed, 9 Jan 2013 21:09:21 +0000 (22:09 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 9 Jan 2013 21:09:21 +0000 (22:09 +0100)
Fixes #906
Fixes #910

wcfsetup/install/files/lib/data/cronjob/Cronjob.class.php
wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php

index 0e151e4dd7f1f1eb4df99dba04db9d3397a54e6b..65ad448d7a77fab52a3cc4d2e5e0de519a81841b 100644 (file)
@@ -54,7 +54,10 @@ class Cronjob extends DatabaseObject {
        public function getNextExec($timeBase = null) {
                if ($timeBase === null) {
                        if ($this->lastExec) {
-                               $timeBase = $this->lastExec;
+                               $timeBase = $this->lastExec + 120;
+                               if ($timeBase < TIME_NOW) {
+                                       $timeBase = TIME_NOW + 120;
+                               }
                        }
                        else {
                                // first time setup
index dd17649513e6e195985b49a1712a4a3cbc3dc8ea..f7a8ba076797088c743130492438058c6d59b325 100644 (file)
@@ -106,15 +106,13 @@ class CronjobScheduler extends SingletonFactory {
                        FROM    wcf".WCF_N."_cronjob cronjob
                        WHERE   (cronjob.nextExec <= ? OR cronjob.afterNextExec <= ?)
                                AND cronjob.isDisabled = ?
-                               AND cronjob.failCount < ?
-                               AND cronjob.state = ?";
+                               AND cronjob.failCount < ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute(array(
                        TIME_NOW,
                        TIME_NOW,
                        0,
-                       Cronjob::MAX_FAIL_COUNT,
-                       Cronjob::READY
+                       Cronjob::MAX_FAIL_COUNT
                ));
                while ($row = $statement->fetchArray()) {
                        $cronjob = new Cronjob(null, $row);