mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[feature/system-cron] Fixes to make cron actually run.
PHPBB3-9596
This commit is contained in:
parent
ea3b98ab49
commit
763dc86c16
6 changed files with 26 additions and 17 deletions
|
@ -243,5 +243,5 @@ foreach ($cache->obtain_hooks() as $hook)
|
||||||
if (!$config['use_system_cron'])
|
if (!$config['use_system_cron'])
|
||||||
{
|
{
|
||||||
include($phpbb_root_path . 'includes/cron/cron_manager.' . $phpEx);
|
include($phpbb_root_path . 'includes/cron/cron_manager.' . $phpEx);
|
||||||
$cron = new cron();
|
$cron = new cron_manager();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,12 +48,16 @@ function do_cron($run_tasks)
|
||||||
garbage_collection();
|
garbage_collection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cron_lock = new cron_lock;
|
||||||
if ($cron_lock->lock())
|
if ($cron_lock->lock())
|
||||||
{
|
{
|
||||||
if ($config['use_system_cron'])
|
if ($config['use_system_cron'])
|
||||||
{
|
{
|
||||||
$use_shutdown_function = false;
|
$use_shutdown_function = false;
|
||||||
|
|
||||||
|
include($phpbb_root_path . 'includes/cron/cron_manager.' . $phpEx);
|
||||||
|
$cron = new cron_manager;
|
||||||
|
|
||||||
$run_tasks = $cron->find_all_ready_tasks();
|
$run_tasks = $cron->find_all_ready_tasks();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -63,13 +67,19 @@ if ($cron_lock->lock())
|
||||||
|
|
||||||
output_image();
|
output_image();
|
||||||
|
|
||||||
|
// 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);
|
$task = $cron->find_task($cron_type);
|
||||||
if ($task) {
|
if ($task)
|
||||||
if ($task->is_parametrized()) {
|
{
|
||||||
|
if ($task->is_parametrized())
|
||||||
|
{
|
||||||
$task->parse_parameters($_GET);
|
$task->parse_parameters($_GET);
|
||||||
}
|
}
|
||||||
if ($task->is_ready()) {
|
if ($task->is_ready())
|
||||||
if ($use_shutdown_function && !$task->is_shutdown_function_safe()) {
|
{
|
||||||
|
if ($use_shutdown_function && !$task->is_shutdown_function_safe())
|
||||||
|
{
|
||||||
$use_shutdown_function = false;
|
$use_shutdown_function = false;
|
||||||
}
|
}
|
||||||
$run_tasks = array($task);
|
$run_tasks = array($task);
|
||||||
|
|
|
@ -61,7 +61,7 @@ class cron_manager
|
||||||
{
|
{
|
||||||
// ignore ., .. and dot directories
|
// ignore ., .. and dot directories
|
||||||
// todo: change is_dir to account for symlinks
|
// todo: change is_dir to account for symlinks
|
||||||
if ($entry[0] == '.' || !is_dir($entry))
|
if ($entry[0] == '.' || !is_dir("$tasks_root_path/$entry"))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -76,11 +76,14 @@ class cron_manager
|
||||||
{
|
{
|
||||||
$path = $phpbb_root_path . 'includes/cron/tasks/' . $task_dir;
|
$path = $phpbb_root_path . 'includes/cron/tasks/' . $task_dir;
|
||||||
$dir = opendir($path);
|
$dir = opendir($path);
|
||||||
while (($entry = readdir($dir)) !== false && substr($entry, -$ext_length) == $ext)
|
while (($entry = readdir($dir)) !== false)
|
||||||
|
{
|
||||||
|
if (substr($entry, -$ext_length) == $ext)
|
||||||
{
|
{
|
||||||
$task_file = substr($entry, 0, -$ext_length);
|
$task_file = substr($entry, 0, -$ext_length);
|
||||||
$task_files[] = array($task_dir, $task_file);
|
$task_files[] = array($task_dir, $task_file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
closedir($dir);
|
closedir($dir);
|
||||||
}
|
}
|
||||||
return $task_files;
|
return $task_files;
|
||||||
|
@ -106,7 +109,7 @@ class cron_manager
|
||||||
$class = "cron_task_${mod}_${filename}";
|
$class = "cron_task_${mod}_${filename}";
|
||||||
if (!class_exists($class))
|
if (!class_exists($class))
|
||||||
{
|
{
|
||||||
include($phpbb_root_path . "includes/cron/$mod/$filename.$phpEx");
|
include($phpbb_root_path . "includes/cron/tasks/$mod/$filename.$phpEx");
|
||||||
}
|
}
|
||||||
$object = new $class;
|
$object = new $class;
|
||||||
$wrapper = new cron_task_wrapper($object);
|
$wrapper = new cron_task_wrapper($object);
|
||||||
|
|
|
@ -34,11 +34,6 @@ if (!class_exists('cron_task'))
|
||||||
*/
|
*/
|
||||||
abstract class cron_task_base implements cron_task
|
abstract class cron_task_base implements cron_task
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Runs this cron task.
|
|
||||||
*/
|
|
||||||
abstract public function run();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this cron task can run, given current board configuration.
|
* Returns whether this cron task can run, given current board configuration.
|
||||||
*
|
*
|
||||||
|
|
|
@ -33,6 +33,7 @@ class cron_task_core_tidy_database extends cron_task_base
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
|
global $phpbb_root_path, $phpEx;
|
||||||
if (!function_exists('tidy_database'))
|
if (!function_exists('tidy_database'))
|
||||||
{
|
{
|
||||||
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
||||||
|
|
|
@ -28,7 +28,7 @@ if (!class_exists('cron_task_base'))
|
||||||
*
|
*
|
||||||
* @package phpBB3
|
* @package phpBB3
|
||||||
*/
|
*/
|
||||||
class cron_task_core_tidy_sessions extends cron_task_base
|
class cron_task_core_tidy_search extends cron_task_base
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Runs this cron task.
|
* Runs this cron task.
|
||||||
|
|
Loading…
Add table
Reference in a new issue