Skip to content

Commit a219931

Browse files
author
Till Brehm
committed
Revert "Improved cron debug script"
This reverts commit b34b1ad. Fixes #5657
1 parent 0aa4f2d commit a219931

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

server/cron_debug.php

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,20 @@
3939
$conf['server_id'] = intval($conf['server_id']);
4040

4141
// Load required base-classes
42-
$app->uses('ini_parser,file,services,getconf,system,cron,functions');
42+
$app->uses('modules,plugins,ini_parser,file,services,getconf,system,cron,functions');
4343
$app->load('libdatetime,cronjob');
4444

4545
// Path settings
4646
$path = SCRIPT_PATH . '/lib/classes/cron.d';
4747

4848
//** Get commandline options
49-
$cmd_opt = getopt('', array('cronjob::', 'force', 'firstrun'));
49+
$cmd_opt = getopt('', array('cronjob::'));
5050

5151
if(isset($cmd_opt['cronjob']) && is_file($path.'/'.$cmd_opt['cronjob'])) {
5252
// Cronjob that shell be run
5353
$cronjob_file = $cmd_opt['cronjob'];
5454
} else {
55-
echo "Usage example: php cron_debug.php --cronjob=100-mailbox_stats.inc.php [--force] [--firstrun]\n" ;
56-
echo "Available cronjobs:\n";
57-
foreach(glob($path.'/*-*.inc.php') as $cronjob) {
58-
echo basename($cronjob)."\n";
59-
}
60-
die();
55+
die('Usage example: php cron_debug.php --cronjob=100-mailbox_stats.inc.php');
6156
}
6257

6358
// Load and run the cronjob
@@ -66,20 +61,8 @@
6661
include $path . '/' . $cronjob_file;
6762
$class_name = 'cronjob_' . $name;
6863
$cronjob = new $class_name();
69-
70-
if(isset($cmd_opt['force'])) {
71-
$app->db->query("UPDATE `sys_cron` SET `running` = 0 WHERE `name` = ?", $class_name);
72-
}
73-
74-
$cronjob->onPrepare();
75-
$cronjob->onBeforeRun(isset($cmd_opt['firstrun']));
76-
if(!$cronjob->isRunning()) {
77-
$app->db->query("UPDATE `sys_cron` SET `running` = ? WHERE `name` = ?", ($cronjob->canBeRunInParallel() !== true ? "1" : "0"), $class_name);
78-
$cronjob->onRunJob();
79-
$cronjob->onAfterRun();
80-
$cronjob->onCompleted();
81-
}
64+
$cronjob->run(true);
8265

8366
die("finished.\n");
8467

85-
?>
68+
?>

0 commit comments

Comments
 (0)