mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-07 01:06:48 +02:00
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 ...
This commit is contained in:
@@ -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())
|
||||
{
|
||||
if ($task->is_parametrized())
|
||||
{
|
||||
$task->parse_parameters($request);
|
||||
}
|
||||
if ($task->is_ready())
|
||||
{
|
||||
$run_tasks = array($task);
|
||||
}
|
||||
$task->parse_parameters($request);
|
||||
}
|
||||
if ($task->is_ready())
|
||||
{
|
||||
$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";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user