Fixes cronjob issues
authorMatthias Schmidt <gravatronics@live.com>
Sat, 27 Apr 2013 22:54:23 +0000 (00:54 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 27 Apr 2013 22:54:23 +0000 (00:54 +0200)
Closes #1185
Closes #1197

wcfsetup/install/files/acp/templates/cronjobList.tpl
wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php
wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php

index b28628401235da8ad5eff2ba970bb2607648b7a0..efcf6bfa2febfb1e8a9446587436d61480355bba 100644 (file)
                        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();
                                        }
                                });
index 29c3b21b335b334deb7d8cc125a221afeba3d7f7..ce1835b7ade2d685362263456012930ba56efb95 100644 (file)
@@ -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 <http://opensource.org/licenses/lgpl-license.php>
  * @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);
index d43db9af19a010be61b893d2677a81b6673c52e4..2f029a2cdbce2539b1f4b84fb202ad70afa3ffc7 100644 (file)
@@ -131,6 +131,7 @@ class CronjobScheduler extends SingletonFactory {
                                // disable cronjob
                                if ($failCount == Cronjob::MAX_FAIL_COUNT) {
                                        $data['isDisabled'] = 1;
+                                       $data['state'] = 0;
                                        $executeCronjob = false;
                                }
                        }