Disable disabling of failed system cronjobs
authorjoshuaruesweg <ruesweg@woltlab.com>
Sat, 2 Jan 2021 15:10:37 +0000 (16:10 +0100)
committerjoshuaruesweg <ruesweg@woltlab.com>
Sat, 2 Jan 2021 15:10:37 +0000 (16:10 +0100)
Fixes #3841

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

index 0af71a0cd8ffc94b10fc131e1f1bd82c198f33d2..b11fb61b43be22fb3f67ccfe061afb2d90ecf9c3 100644 (file)
@@ -130,11 +130,17 @@ class CronjobScheduler extends SingletonFactory {
                                                $data['failCount'] = $cronjob->failCount + 1;
                                                
                                                // The cronjob exceeded the maximum fail count.
-                                               // Thus it must be disabled.
-                                               if ($data['failCount'] > Cronjob::MAX_FAIL_COUNT) {
+                                               // Cronjobs which can be disabled, should be disabled.
+                                               if ($cronjob->canBeDisabled && $data['failCount'] >= Cronjob::MAX_FAIL_COUNT) {
                                                        $data['isDisabled'] = 1;
                                                        $data['failCount'] = 0;
                                                }
+                                               else if ($data['failCount'] >= Cronjob::MAX_FAIL_COUNT) {
+                                                       // Reset failCount for cronjobs, which can't be disabled to 
+                                                       // MAX_FAIL_COUNT - 1, because the column has a max length
+                                                       // which should not be reached.
+                                                       $data['failCount'] = Cronjob::MAX_FAIL_COUNT - 1;
+                                               }
                                                // fall through
                                        case Cronjob::PENDING:
                                                // The cronjob spent two periods in the PENDING state.