From 77d7238eef84f498fc024fa8b9e06f187dd0f2a6 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 14 Apr 2010 16:14:32 -0400 Subject: [feature/system-cron] WIP on making cron tasks runnable via system cron PHPBB3-9596 --- phpBB/includes/cron/standard.php | 163 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 phpBB/includes/cron/standard.php (limited to 'phpBB/includes/cron/standard.php') diff --git a/phpBB/includes/cron/standard.php b/phpBB/includes/cron/standard.php new file mode 100644 index 0000000000..1cb8738f17 --- /dev/null +++ b/phpBB/includes/cron/standard.php @@ -0,0 +1,163 @@ + array( + 'custom_condition' => true, + 'run_from_system' => true, + ), + 'prune_forum' => array( + 'custom_condition' => true, + 'custom_code' => true, + ), + 'queue' => array( + 'custom_condition' => true, + 'interval_config' => 'queue_interval_config', + 'last_run_config' => 'last_queue_run', + 'run_from_phpbb' => true, + 'run_from_system' => true, + 'shutdown_function_condition' => true, + ), + 'tidy_cache' => array( + 'custom_condition' => true, + 'interval_config' => 'cache_gc', + 'last_run_config' => 'cache_last_gc', + 'run_from_phpbb' => true, + 'run_from_system' => true, + ), + 'tidy_database' => array( + 'interval_config' => 'database_gc', + 'last_run_config' => 'database_last_gc', + 'run_from_phpbb' => true, + 'run_from_system' => true, + ), + 'tidy_search' => array( + 'interval_config' => 'search_gc', + 'last_run_config' => 'search_last_gc', + 'run_from_phpbb' => true, + 'run_from_system' => true, + ), + 'tidy_sessions' => array( + 'interval_config' => 'session_gc', + 'last_run_config' => 'session_last_gc', + 'run_from_phpbb' => true, + 'run_from_system' => true, + ), + 'tidy_warnings' => array( + 'enable_config' => 'warnings_expire_days', + 'interval_config' => 'warnings_gc', + 'last_run_config' => 'warnings_last_gc', + 'run_from_phpbb' => true, + 'run_from_system' => true, + ), + ); + + function prune_forum_condition($forum_data) { + return $forum_data['enable_prune'] && $forum_data['prune_next'] < time(); + } + + function prune_forum_code($forum_id) { + global $phpbb_root_path, $phpEx; + return 'cron'; + } + + function run_prune_forum() { + } + + function queue_condition() { + global $phpbb_root_path, $phpEx; + return file_exists($phpbb_root_path . 'cache/queue.' . $phpEx); + } + + function queue_shutdown_function_condition() { + global $config; + return !$config['smtp_delivery']; + } + + function run_queue() { + global $phpbb_root_path, $phpEx; + include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); + $queue = new queue(); + $queue->process(); + } + + function tidy_cache_condition() { + global $cache; + return method_exists($cache, 'tidy'); + } + + function run_tidy_cache() { + global $cache; + $cache->tidy(); + } + + function run_tidy_database() { + include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + tidy_database(); + } + + function tidy_search_condition() { + global $phpbb_root_path, $phpEx, $config; + + // Select the search method + $search_type = basename($config['search_type']); + + return file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx); + } + + function run_tidy_search() { + global $phpbb_root_path, $phpEx, $config, $error; + + // Select the search method + $search_type = basename($config['search_type']); + + include_once("{$phpbb_root_path}includes/search/$search_type.$phpEx"); + + // We do some additional checks in the module to ensure it can actually be utilised + $error = false; + $search = new $search_type($error); + + if (!$error) { + $search->tidy(); + } + } + + function run_tidy_sessions() { + global $user; + $user->session_gc(); + } + + function run_tidy_warnings() { + include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + tidy_warnings(); + } +} -- cgit v1.2.1