From: Matthias Schmidt Date: Sat, 27 Apr 2013 22:54:23 +0000 (+0200) Subject: Fixes cronjob issues X-Git-Tag: 2.0.0_Beta_1~274^2~9 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cafc578a2dbcefa87e7173a12587cf294d6b823c;p=GitHub%2FWoltLab%2FWCF.git Fixes cronjob issues Closes #1185 Closes #1197 --- diff --git a/wcfsetup/install/files/acp/templates/cronjobList.tpl b/wcfsetup/install/files/acp/templates/cronjobList.tpl index b286284012..efcf6bfa2f 100644 --- a/wcfsetup/install/files/acp/templates/cronjobList.tpl +++ b/wcfsetup/install/files/acp/templates/cronjobList.tpl @@ -18,10 +18,11 @@ success: function(data, statusText, jqXHR) { $('.jsCronjobRow').each(function(index, row) { var $button = $(row).find('.jsExecuteButton'); + var $objectID = ($button).data('objectID'); - if (WCF.inArray($($button).data('objectID'), data.objectIDs)) { + if (WCF.inArray($objectID, data.objectIDs) && data.returnValues[$objectID]) { // insert feedback here - $(row).find('td.columnNextExec').html(data.returnValues[$($button).data('objectID')].formatted); + $(row).find('td.columnNextExec').html(data.returnValues[$objectID].formatted); $(row).wcfHighlight(); } }); diff --git a/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php b/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php index 29c3b21b33..ce1835b7ad 100644 --- a/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php +++ b/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php @@ -11,8 +11,8 @@ use wcf\util\DateUtil; /** * Executes cronjob-related actions. * - * @author Tim Düsterhus, Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @author Tim Duesterhus, Alexander Ebert + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.cronjob @@ -136,16 +136,30 @@ class CronjobAction extends AbstractDatabaseObjectAction implements IToggleActio CronjobLogEditor::create(array( 'cronjobID' => $cronjob->cronjobID, 'execTime' => TIME_NOW, - 'success' => (int) ($error == ''), + 'success' => ($error == '' ? 1 : 0), 'error' => $error )); - + // calculate next exec-time $nextExec = $cronjob->getNextExec(); - $cronjob->update(array( + $data = array( + 'lastExec' => TIME_NOW, 'nextExec' => $nextExec, 'afterNextExec' => $cronjob->getNextExec(($nextExec + 120)) - )); + ); + + // if no error: reset fail counter + if ($error == '') { + $data['failCount'] = 0; + + // if cronjob has been disabled because of too many + // failed executions, enable it again + if ($cronjob->failCount == Cronjob::MAX_FAIL_COUNT && $cronjob->isDisabled) { + $data['isDisabled'] = 0; + } + } + + $cronjob->update($data); // build the return value $dateTime = DateUtil::getDateTimeByTimestamp($nextExec); diff --git a/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php b/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php index d43db9af19..2f029a2cdb 100644 --- a/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php @@ -131,6 +131,7 @@ class CronjobScheduler extends SingletonFactory { // disable cronjob if ($failCount == Cronjob::MAX_FAIL_COUNT) { $data['isDisabled'] = 1; + $data['state'] = 0; $executeCronjob = false; } }