From: Matthias Schmidt Date: Fri, 22 May 2015 16:37:05 +0000 (+0200) Subject: Add options support for cronjobs X-Git-Tag: 3.0.0_Beta_1~2354 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0fb52d6b0be05e947b6a2c8e5ca08df1d9b387d1;p=GitHub%2FWoltLab%2FWCF.git Add options support for cronjobs This implementation is as close to the case where the options would be checked in the cronjob itself. --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 8307cdf491..5a66480d61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### 2.2.0 Alpha 1 (XXXX-YY-ZZ) +* `options` support for cronjobs. * `permissions` and `options` support for event listeners. * `permissions` and `options` support for template listeners. * `wcf\data\TDatabaseObjectOptions` and `wcf\data\TDatabaseObjectPermissions` for database object-bound options and permissions validation. diff --git a/wcfsetup/install/files/lib/data/cronjob/Cronjob.class.php b/wcfsetup/install/files/lib/data/cronjob/Cronjob.class.php index 4bc9e888f8..0a270a9cd0 100644 --- a/wcfsetup/install/files/lib/data/cronjob/Cronjob.class.php +++ b/wcfsetup/install/files/lib/data/cronjob/Cronjob.class.php @@ -1,6 +1,7 @@ execute(new Cronjob($cronjob->cronjobID)); + + // check if all required options are set for cronjob to be executed + // note: a general log is created to avoid confusion why a cronjob + // apperently is not executed while that is indeed the correct internal + // behavior + if ($cronjob->validateOptions()) { + try { + $executable->execute(new Cronjob($cronjob->cronjobID)); + } + catch (\Exception $exception) { } } - catch (\Exception $exception) { } CronjobLogEditor::create(array( 'cronjobID' => $cronjob->cronjobID, diff --git a/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php b/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php index ea460c5b9d..0bd1430e3f 100644 --- a/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/CronjobScheduler.class.php @@ -67,11 +67,20 @@ class CronjobScheduler extends SingletonFactory { )); $logEditor = new CronjobLogEditor($log); - try { - $this->executeCronjob($cronjobEditor, $logEditor); + // check if all required options are set for cronjob to be executed + // note: a general log is created to avoid confusion why a cronjob + // apperently is not executed while that is indeed the correct internal + // behavior + if ($cronjobEditor->validateOptions()) { + try { + $this->executeCronjob($cronjobEditor, $logEditor); + } + catch (SystemException $e) { + $this->logResult($logEditor, $e); + } } - catch (SystemException $e) { - $this->logResult($logEditor, $e); + else { + $this->logResult($logEditor); } // get time of next execution diff --git a/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php index 1364bd0223..f8545ac681 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php @@ -61,6 +61,7 @@ class CronjobPackageInstallationPlugin extends AbstractXMLPackageInstallationPlu 'className' => (isset($data['elements']['classname'])) ? $data['elements']['classname'] : '', 'description' => (isset($data['elements']['description'])) ? $data['elements']['description'] : '', 'isDisabled' => (isset($data['elements']['isdisabled'])) ? intval($data['elements']['isdisabled']) : 0, + 'options' => (isset($data['elements']['options'])) ? $data['elements']['options'] : '', 'startDom' => $data['elements']['startdom'], 'startDow' => $data['elements']['startdow'], 'startHour' => $data['elements']['starthour'], diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 3e66b04853..e38e02c01a 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -321,7 +321,8 @@ CREATE TABLE wcf1_cronjob ( canBeEdited TINYINT(1) NOT NULL DEFAULT 1, canBeDisabled TINYINT(1) NOT NULL DEFAULT 1, state TINYINT(1) NOT NULL DEFAULT 0, - failCount TINYINT(1) NOT NULL DEFAULT 0 + failCount TINYINT(1) NOT NULL DEFAULT 0, + options TEXT ); DROP TABLE IF EXISTS wcf1_cronjob_log;