diff options
author | Andreas Fischer <bantu@phpbb.com> | 2014-05-30 20:12:15 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2014-05-30 20:12:15 +0200 |
commit | bbb83c09c0f53fda26ff0d06083bf900f4babdae (patch) | |
tree | 2b67788b30422a33675e43cc5e23f397508ae948 /phpBB/cron.php | |
parent | 807e000b912a30f3c8010dd7c2acdfa04f6c5392 (diff) | |
parent | fa3a634ae11af0a89000d5770b1c3fae10486195 (diff) | |
download | forums-bbb83c09c0f53fda26ff0d06083bf900f4babdae.tar forums-bbb83c09c0f53fda26ff0d06083bf900f4babdae.tar.gz forums-bbb83c09c0f53fda26ff0d06083bf900f4babdae.tar.bz2 forums-bbb83c09c0f53fda26ff0d06083bf900f4babdae.tar.xz forums-bbb83c09c0f53fda26ff0d06083bf900f4babdae.zip |
Merge pull request #2508 from ptitlazy/ticket/12597
[ticket/12597] Command for executing all available cron tasks
* ptitlazy/ticket/12597: (27 commits)
[ticket/12597] Reformating an acp message
[ticket/12597] Modifiying acp message
[ticket/12597] Fix wrong global variable name
[ticket/12597] Typo correction
[ticket/12597] Typo corrections
[ticket/12597] Changing place of lock release in execute() method
[ticket/12597] Fix test file
[ticket/12597] Typing corrections and improvement of code consistency
[ticket/12597] Fix various mistakes
[ticket/12597] Fix various mistakes
[ticket/12597] Fix visibilty of two functions in run.php
[ticket/12597] Refactoring and test improving
[ticket/12597] Fix language key name
[ticket/12597] Fix coding style and typing mistakes
[ticket/12597] Changes name of command cron:run-all to cron:run.
[ticket/12597] Fix various problems
[ticket/12597] Fix constructor bug and servral doc blocs
[ticket/12597] Modification of return statuses and of test files
[ticket/12597] Fix misplaced release of db lock
[ticket/12597] Change EXECUTE to RUN in language
...
Diffstat (limited to 'phpBB/cron.php')
-rw-r--r-- | phpBB/cron.php | 58 |
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"; } } |