diff --git a/phpBB/includes/cron_task.php b/phpBB/includes/cron_task.php new file mode 100644 index 0000000000..8b9ffacae6 --- /dev/null +++ b/phpBB/includes/cron_task.php @@ -0,0 +1,60 @@ +forum_data = $forum_data; + } + + /** + * Runs this cron task. + */ + public function run() + { + } + + /** + * Returns whether this cron task can run, given current board configuration. + */ + public function is_runnable() + { + global $config; + return !$config['use_system_cron']; + } + + /** + * Returns whether this cron task should run now, because enough time + * has passed since it was last run. + */ + public function should_run() + { + return $this->forum_data['enable_prune'] && $this->forum_data['prune_next'] < time(); + } + + /** + * Returns parameters of this cron task as a query string. + */ + public function get_url_query_string() + { + return 'f=' . $this->forum_data['forum_id']; + } +} diff --git a/phpBB/includes/cron_tasks/standard/queue.php b/phpBB/includes/cron_tasks/standard/queue.php new file mode 100644 index 0000000000..6a69799ef4 --- /dev/null +++ b/phpBB/includes/cron_tasks/standard/queue.php @@ -0,0 +1,64 @@ +process(); + } + + /** + * Returns whether this cron task can run, given current board configuration. + */ + public function is_runnable() + { + global $phpbb_root_path, $phpEx; + return file_exists($phpbb_root_path . 'cache/queue.' . $phpEx); + } + + /** + * Returns whether this cron task should run now, because enough time + * has passed since it was last run. + */ + public function should_run() + { + global $config; + return $config['last_queue_run'] < time() - $config['queue_interval_config']; + } + + /** + * Returns whether this cron task can be run in shutdown function. + */ + public function is_shutdown_function_safe() + { + global $config; + return !$config['smtp_delivery']; + } +} diff --git a/phpBB/includes/cron_tasks/standard/tidy_cache.php b/phpBB/includes/cron_tasks/standard/tidy_cache.php new file mode 100644 index 0000000000..7c47be06c1 --- /dev/null +++ b/phpBB/includes/cron_tasks/standard/tidy_cache.php @@ -0,0 +1,53 @@ +tidy(); + } + + /** + * Returns whether this cron task can run, given current board configuration. + */ + public function is_runnable() + { + global $cache; + return method_exists($cache, 'tidy'); + } + + /** + * Returns whether this cron task should run now, because enough time + * has passed since it was last run. + */ + public function should_run() + { + global $config; + return $config['cache_last_gc'] < time() - $config['cache_gc']; + } +} diff --git a/phpBB/includes/cron_tasks/standard/tidy_database.php b/phpBB/includes/cron_tasks/standard/tidy_database.php new file mode 100644 index 0000000000..16a17b3538 --- /dev/null +++ b/phpBB/includes/cron_tasks/standard/tidy_database.php @@ -0,0 +1,44 @@ +tidy(); + } + } + + /** + * Returns whether this cron task can run, given current board configuration. + */ + public function is_runnable() + { + 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); + } + + /** + * Returns whether this cron task should run now, because enough time + * has passed since it was last run. + */ + public function should_run() + { + global $config; + return $config['search_last_gc'] < time() - $config['search_gc']; + } +} diff --git a/phpBB/includes/cron_tasks/standard/tidy_sessions.php b/phpBB/includes/cron_tasks/standard/tidy_sessions.php new file mode 100644 index 0000000000..6ff2dee14b --- /dev/null +++ b/phpBB/includes/cron_tasks/standard/tidy_sessions.php @@ -0,0 +1,44 @@ +session_gc(); + } + + /** + * Returns whether this cron task should run now, because enough time + * has passed since it was last run. + */ + public function should_run() + { + global $config; + return $config['session_last_gc'] < time() - $config['session_gc']; + } +} diff --git a/phpBB/includes/cron_tasks/standard/tidy_warnings.php b/phpBB/includes/cron_tasks/standard/tidy_warnings.php new file mode 100644 index 0000000000..059125b18d --- /dev/null +++ b/phpBB/includes/cron_tasks/standard/tidy_warnings.php @@ -0,0 +1,56 @@ +