aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/cron.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/cron.php')
-rw-r--r--phpBB/cron.php58
1 files changed, 14 insertions, 44 deletions
diff --git a/phpBB/cron.php b/phpBB/cron.php
index e070c8f5fb..611d5d4aaf 100644
--- a/phpBB/cron.php
+++ b/phpBB/cron.php
@@ -37,25 +37,6 @@ function output_image()
flush();
}
-function do_cron($cron_lock, $run_tasks)
-{
- global $config;
-
- foreach ($run_tasks as $task)
- {
- if (defined('DEBUG') && $config['use_system_cron'])
- {
- echo "[phpBB cron] Running task '{$task->get_name()}'\n";
- }
-
- $task->run();
- }
-
- // Unloading cache and closing db after having done the dirty work.
- $cron_lock->release();
- garbage_collection();
-}
-
// Thanks to various fatal errors and lack of try/finally, it is quite easy to leave
// the cron lock locked, especially when working on cron-related code.
//
@@ -63,47 +44,36 @@ function do_cron($cron_lock, $run_tasks)
//
// If DEBUG is defined and cron lock cannot be obtained, a message will be printed.
-if (!$config['use_system_cron'])
-{
- $cron_type = request_var('cron_type', '');
+$cron_type = request_var('cron_type', '');
- // Comment this line out for debugging so the page does not return an image.
- output_image();
-}
+// Comment this line out for debugging so the page does not return an image.
+output_image();
$cron_lock = $phpbb_container->get('cron.lock_db');
if ($cron_lock->acquire())
{
$cron = $phpbb_container->get('cron.manager');
- if ($config['use_system_cron'])
+ $task = $cron->find_task($cron_type);
+ if ($task)
{
- $run_tasks = $cron->find_all_ready_tasks();
- }
- else
- {
- // If invalid task is specified, empty $run_tasks is passed to do_cron which then does nothing
- $run_tasks = array();
- $task = $cron->find_task($cron_type);
- if ($task)
+ if ($task->is_parametrized())
+ {
+ $task->parse_parameters($request);
+ }
+ if ($task->is_ready())
{
- if ($task->is_parametrized())
- {
- $task->parse_parameters($request);
- }
- if ($task->is_ready())
- {
- $run_tasks = array($task);
- }
+ $task->run();
+ garbage_collection();
}
}
+ $cron_lock->release();
- do_cron($cron_lock, $run_tasks);
}
else
{
if (defined('DEBUG'))
{
- echo "Could not obtain cron lock.\n";
+ echo $user->lang('CRON_LOCK_ERROR') . "\n";
}
}