From 794d376be4d3587f21bf7149de428a37deaa71c8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 28 Oct 2010 21:35:53 +0200 Subject: [feature/system-cron] rename tasks to task PHPBB3-9596 --- phpBB/includes/cron/task/core/prune_all_forums.php | 74 +++++++++++ phpBB/includes/cron/task/core/prune_forum.php | 139 +++++++++++++++++++++ phpBB/includes/cron/task/core/queue.php | 73 +++++++++++ phpBB/includes/cron/task/core/tidy_cache.php | 58 +++++++++ phpBB/includes/cron/task/core/tidy_database.php | 53 ++++++++ phpBB/includes/cron/task/core/tidy_search.php | 80 ++++++++++++ phpBB/includes/cron/task/core/tidy_sessions.php | 49 ++++++++ phpBB/includes/cron/task/core/tidy_warnings.php | 64 ++++++++++ 8 files changed, 590 insertions(+) create mode 100644 phpBB/includes/cron/task/core/prune_all_forums.php create mode 100644 phpBB/includes/cron/task/core/prune_forum.php create mode 100644 phpBB/includes/cron/task/core/queue.php create mode 100644 phpBB/includes/cron/task/core/tidy_cache.php create mode 100644 phpBB/includes/cron/task/core/tidy_database.php create mode 100644 phpBB/includes/cron/task/core/tidy_search.php create mode 100644 phpBB/includes/cron/task/core/tidy_sessions.php create mode 100644 phpBB/includes/cron/task/core/tidy_warnings.php (limited to 'phpBB/includes/cron/task') diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/includes/cron/task/core/prune_all_forums.php new file mode 100644 index 0000000000..de7ea557b0 --- /dev/null +++ b/phpBB/includes/cron/task/core/prune_all_forums.php @@ -0,0 +1,74 @@ +sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + if ($row['prune_days']) + { + auto_prune($row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']); + } + + if ($row['prune_viewed']) + { + auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']); + } + } + $db->sql_freeresult($result); + } + + /** + * Returns whether this cron task can run, given current board configuration. + */ + public function is_runnable() + { + global $config; + return (bool) $config['use_system_cron']; + } +} diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php new file mode 100644 index 0000000000..7728932d7e --- /dev/null +++ b/phpBB/includes/cron/task/core/prune_forum.php @@ -0,0 +1,139 @@ +forum_data = $forum_data; + } + else + { + $this->forum_data = null; + } + } + + /** + * Runs this cron task. + */ + public function run() + { + global $phpbb_root_path, $phpEx; + if (!function_exists('auto_prune')) + { + include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + } + + if ($this->forum_data['prune_days']) + { + auto_prune($this->forum_data['forum_id'], 'posted', $this->forum_data['forum_flags'], $this->forum_data['prune_days'], $this->forum_data['prune_freq']); + } + + if ($this->forum_data['prune_viewed']) + { + auto_prune($this->forum_data['forum_id'], 'viewed', $this->forum_data['forum_flags'], $this->forum_data['prune_viewed'], $this->forum_data['prune_freq']); + } + } + + /** + * Returns whether this cron task can run, given current board configuration. + */ + public function is_runnable() + { + global $config; + return !$config['use_system_cron'] && $this->forum_data; + } + + /** + * 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 an array. + * + * The array has one key, f, whose value is id of the forum to be pruned. + */ + public function get_parameters() + { + return array('f' => $this->forum_data['forum_id']); + } + + /** + * Parses parameters found in $params, which is an array. + * + * $params may contain user input and is not trusted. + * + * $params is expected to have a key f whose value is id of the forum to be pruned. + */ + public function parse_parameters($params) + { + global $db; + + $this->forum_data = null; + if (isset($params['f'])) + { + $forum_id = (int) $params['f']; + + $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq + FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row) + { + $this->forum_data = $row; + } + } + } +} diff --git a/phpBB/includes/cron/task/core/queue.php b/phpBB/includes/cron/task/core/queue.php new file mode 100644 index 0000000000..dffaf5aed4 --- /dev/null +++ b/phpBB/includes/cron/task/core/queue.php @@ -0,0 +1,73 @@ +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; + // A user reported using the mail() function while using shutdown does not work. We do not want to risk that. + return !$config['smtp_delivery']; + } +} diff --git a/phpBB/includes/cron/task/core/tidy_cache.php b/phpBB/includes/cron/task/core/tidy_cache.php new file mode 100644 index 0000000000..72843ba680 --- /dev/null +++ b/phpBB/includes/cron/task/core/tidy_cache.php @@ -0,0 +1,58 @@ +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/task/core/tidy_database.php b/phpBB/includes/cron/task/core/tidy_database.php new file mode 100644 index 0000000000..6724ec092e --- /dev/null +++ b/phpBB/includes/cron/task/core/tidy_database.php @@ -0,0 +1,53 @@ +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/task/core/tidy_sessions.php b/phpBB/includes/cron/task/core/tidy_sessions.php new file mode 100644 index 0000000000..ecf0be3978 --- /dev/null +++ b/phpBB/includes/cron/task/core/tidy_sessions.php @@ -0,0 +1,49 @@ +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/task/core/tidy_warnings.php b/phpBB/includes/cron/task/core/tidy_warnings.php new file mode 100644 index 0000000000..6ef6a17fab --- /dev/null +++ b/phpBB/includes/cron/task/core/tidy_warnings.php @@ -0,0 +1,64 @@ + Date: Thu, 28 Oct 2010 21:41:53 +0200 Subject: [feature/system-cron] remove conditional includes in favour of autoloading PHPBB3-9596 --- phpBB/includes/cron/task/core/prune_all_forums.php | 5 ----- phpBB/includes/cron/task/core/prune_forum.php | 5 ----- phpBB/includes/cron/task/core/queue.php | 5 ----- phpBB/includes/cron/task/core/tidy_cache.php | 5 ----- phpBB/includes/cron/task/core/tidy_database.php | 5 ----- phpBB/includes/cron/task/core/tidy_search.php | 5 ----- phpBB/includes/cron/task/core/tidy_sessions.php | 5 ----- phpBB/includes/cron/task/core/tidy_warnings.php | 5 ----- 8 files changed, 40 deletions(-) (limited to 'phpBB/includes/cron/task') diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/includes/cron/task/core/prune_all_forums.php index de7ea557b0..b218aac6c5 100644 --- a/phpBB/includes/cron/task/core/prune_all_forums.php +++ b/phpBB/includes/cron/task/core/prune_all_forums.php @@ -16,11 +16,6 @@ if (!defined('IN_PHPBB')) exit; } -if (!class_exists('cron_task_base')) -{ - include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); -} - /** * Prune all forums cron task. * diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php index 7728932d7e..090a90c212 100644 --- a/phpBB/includes/cron/task/core/prune_forum.php +++ b/phpBB/includes/cron/task/core/prune_forum.php @@ -16,11 +16,6 @@ if (!defined('IN_PHPBB')) exit; } -if (!class_exists('cron_task_base')) -{ - include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); -} - /** * Prune one forum cron task. * diff --git a/phpBB/includes/cron/task/core/queue.php b/phpBB/includes/cron/task/core/queue.php index dffaf5aed4..d32e133973 100644 --- a/phpBB/includes/cron/task/core/queue.php +++ b/phpBB/includes/cron/task/core/queue.php @@ -16,11 +16,6 @@ if (!defined('IN_PHPBB')) exit; } -if (!class_exists('cron_task_base')) -{ - include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); -} - /** * Queue cron task. Sends email and jabber messages queued by other scripts. * diff --git a/phpBB/includes/cron/task/core/tidy_cache.php b/phpBB/includes/cron/task/core/tidy_cache.php index 72843ba680..69038a8a5a 100644 --- a/phpBB/includes/cron/task/core/tidy_cache.php +++ b/phpBB/includes/cron/task/core/tidy_cache.php @@ -16,11 +16,6 @@ if (!defined('IN_PHPBB')) exit; } -if (!class_exists('cron_task_base')) -{ - include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); -} - /** * Tidy cache cron task. * diff --git a/phpBB/includes/cron/task/core/tidy_database.php b/phpBB/includes/cron/task/core/tidy_database.php index 6724ec092e..3ae8c42273 100644 --- a/phpBB/includes/cron/task/core/tidy_database.php +++ b/phpBB/includes/cron/task/core/tidy_database.php @@ -16,11 +16,6 @@ if (!defined('IN_PHPBB')) exit; } -if (!class_exists('cron_task_base')) -{ - include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); -} - /** * Tidy database cron task. * diff --git a/phpBB/includes/cron/task/core/tidy_search.php b/phpBB/includes/cron/task/core/tidy_search.php index e821310c9f..e21d48c13a 100644 --- a/phpBB/includes/cron/task/core/tidy_search.php +++ b/phpBB/includes/cron/task/core/tidy_search.php @@ -16,11 +16,6 @@ if (!defined('IN_PHPBB')) exit; } -if (!class_exists('cron_task_base')) -{ - include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); -} - /** * Tidy search cron task. * diff --git a/phpBB/includes/cron/task/core/tidy_sessions.php b/phpBB/includes/cron/task/core/tidy_sessions.php index ecf0be3978..ea6aa70699 100644 --- a/phpBB/includes/cron/task/core/tidy_sessions.php +++ b/phpBB/includes/cron/task/core/tidy_sessions.php @@ -16,11 +16,6 @@ if (!defined('IN_PHPBB')) exit; } -if (!class_exists('cron_task_base')) -{ - include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); -} - /** * Tidy sessions cron task. * diff --git a/phpBB/includes/cron/task/core/tidy_warnings.php b/phpBB/includes/cron/task/core/tidy_warnings.php index 6ef6a17fab..257c116b5e 100644 --- a/phpBB/includes/cron/task/core/tidy_warnings.php +++ b/phpBB/includes/cron/task/core/tidy_warnings.php @@ -16,11 +16,6 @@ if (!defined('IN_PHPBB')) exit; } -if (!class_exists('cron_task_base')) -{ - include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); -} - /** * Tidy warnings cron task. * -- cgit v1.2.1 From a9e0f9947d1d71779a6c02dbc4c40f70f6a98723 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 28 Oct 2010 22:26:49 +0200 Subject: [feature/system-cron] add phpbb_ prefix to all class names PHPBB3-9596 --- phpBB/includes/cron/task/core/prune_all_forums.php | 2 +- phpBB/includes/cron/task/core/prune_forum.php | 2 +- phpBB/includes/cron/task/core/queue.php | 2 +- phpBB/includes/cron/task/core/tidy_cache.php | 2 +- phpBB/includes/cron/task/core/tidy_database.php | 2 +- phpBB/includes/cron/task/core/tidy_search.php | 2 +- phpBB/includes/cron/task/core/tidy_sessions.php | 2 +- phpBB/includes/cron/task/core/tidy_warnings.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/cron/task') diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/includes/cron/task/core/prune_all_forums.php index b218aac6c5..154409a37c 100644 --- a/phpBB/includes/cron/task/core/prune_all_forums.php +++ b/phpBB/includes/cron/task/core/prune_all_forums.php @@ -25,7 +25,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class cron_task_core_prune_all_forums extends cron_task_base +class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base { /** * Runs this cron task. diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php index 090a90c212..eb01e535a9 100644 --- a/phpBB/includes/cron/task/core/prune_forum.php +++ b/phpBB/includes/cron/task/core/prune_forum.php @@ -25,7 +25,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class cron_task_core_prune_forum extends cron_task_base implements parametrized_cron_task +class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements phpbb_parametrized_cron_task { private $forum_data; diff --git a/phpBB/includes/cron/task/core/queue.php b/phpBB/includes/cron/task/core/queue.php index d32e133973..271a03937d 100644 --- a/phpBB/includes/cron/task/core/queue.php +++ b/phpBB/includes/cron/task/core/queue.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class cron_task_core_queue extends cron_task_base +class phpbb_cron_task_core_queue extends phpbb_cron_task_base { /** * Runs this cron task. diff --git a/phpBB/includes/cron/task/core/tidy_cache.php b/phpBB/includes/cron/task/core/tidy_cache.php index 69038a8a5a..9656275742 100644 --- a/phpBB/includes/cron/task/core/tidy_cache.php +++ b/phpBB/includes/cron/task/core/tidy_cache.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class cron_task_core_tidy_cache extends cron_task_base +class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base { /** * Runs this cron task. diff --git a/phpBB/includes/cron/task/core/tidy_database.php b/phpBB/includes/cron/task/core/tidy_database.php index 3ae8c42273..a2a0b84a68 100644 --- a/phpBB/includes/cron/task/core/tidy_database.php +++ b/phpBB/includes/cron/task/core/tidy_database.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class cron_task_core_tidy_database extends cron_task_base +class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base { /** * Runs this cron task. diff --git a/phpBB/includes/cron/task/core/tidy_search.php b/phpBB/includes/cron/task/core/tidy_search.php index e21d48c13a..dffc44174c 100644 --- a/phpBB/includes/cron/task/core/tidy_search.php +++ b/phpBB/includes/cron/task/core/tidy_search.php @@ -23,7 +23,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class cron_task_core_tidy_search extends cron_task_base +class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base { /** * Runs this cron task. diff --git a/phpBB/includes/cron/task/core/tidy_sessions.php b/phpBB/includes/cron/task/core/tidy_sessions.php index ea6aa70699..1d471f9333 100644 --- a/phpBB/includes/cron/task/core/tidy_sessions.php +++ b/phpBB/includes/cron/task/core/tidy_sessions.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class cron_task_core_tidy_sessions extends cron_task_base +class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base { /** * Runs this cron task. diff --git a/phpBB/includes/cron/task/core/tidy_warnings.php b/phpBB/includes/cron/task/core/tidy_warnings.php index 257c116b5e..5120369178 100644 --- a/phpBB/includes/cron/task/core/tidy_warnings.php +++ b/phpBB/includes/cron/task/core/tidy_warnings.php @@ -23,7 +23,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class cron_task_core_tidy_warnings extends cron_task_base +class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base { /** * Runs this cron task. -- cgit v1.2.1 From bd58fa49c000e99d049cbd96306315e1bd35b938 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 28 Oct 2010 22:30:44 +0200 Subject: [feature/system-cron] make parameterized interface autoloadable also extract it to a separate file PHPBB3-9596 --- phpBB/includes/cron/task/core/prune_forum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/cron/task') diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php index eb01e535a9..5efcde4102 100644 --- a/phpBB/includes/cron/task/core/prune_forum.php +++ b/phpBB/includes/cron/task/core/prune_forum.php @@ -25,7 +25,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements phpbb_parametrized_cron_task +class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements phpbb_cron_task_parametrized { private $forum_data; -- cgit v1.2.1 From 132d2c2bd85bac6ed87ea3c57de27a9675192f29 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 29 Oct 2010 11:40:18 +0200 Subject: [feature/system-cron] adjust some last filenames to make autoloading work PHPBB3-9596 --- phpBB/includes/cron/task/base.php | 59 +++++++++++++++++++ phpBB/includes/cron/task/parametrized.php | 49 ++++++++++++++++ phpBB/includes/cron/task/task.php | 48 +++++++++++++++ phpBB/includes/cron/task/wrapper.php | 97 +++++++++++++++++++++++++++++++ 4 files changed, 253 insertions(+) create mode 100644 phpBB/includes/cron/task/base.php create mode 100644 phpBB/includes/cron/task/parametrized.php create mode 100644 phpBB/includes/cron/task/task.php create mode 100644 phpBB/includes/cron/task/wrapper.php (limited to 'phpBB/includes/cron/task') diff --git a/phpBB/includes/cron/task/base.php b/phpBB/includes/cron/task/base.php new file mode 100644 index 0000000000..ba399c18b1 --- /dev/null +++ b/phpBB/includes/cron/task/base.php @@ -0,0 +1,59 @@ +task = $task; + } + + /** + * Returns whether this task is parametrized. + * + * Parametrized tasks accept parameters during initialization and must + * normally be scheduled with parameters. + */ + public function is_parametrized() + { + return $this->task instanceof phpbb_cron_task_parametrized; + } + + /** + * Returns whether the wrapped task is ready to run. + * + * A task is ready to run when it is runnable according to current configuration + * and enough time has passed since it was last run. + */ + public function is_ready() + { + return $this->task->is_runnable() && $this->task->should_run(); + } + + /** + * Returns the name of wrapped task. It is the same as the wrapped class's class name. + */ + public function get_name() + { + return get_class($this->task); + } + + /** + * Returns a url through which this task may be invoked via web. + */ + public function get_url() + { + global $phpbb_root_path, $phpEx; + + $name = $this->get_name(); + if ($this->is_parametrized()) + { + $params = $this->task->get_parameters(); + $extra = ''; + foreach ($params as $key => $value) + { + $extra .= '&' . $key . '=' . urlencode($value); + } + } + else + { + $extra = ''; + } + $url = append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=' . $name . $extra); + return $url; + } + + /** + * Forwards all other method calls to the wrapped task implementation. + */ + public function __call($name, $args) + { + return call_user_func_array(array($this->task, $name), $args); + } +} -- cgit v1.2.1 From 4f86b4d205589a11c5c4403c215db522dd8fbac4 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 29 Oct 2010 11:42:47 +0200 Subject: [feature/system-cron] add spaces to comply with coding guidelines PHPBB3-9596 --- phpBB/includes/cron/task/core/prune_forum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/cron/task') diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php index 5efcde4102..440dc5e358 100644 --- a/phpBB/includes/cron/task/core/prune_forum.php +++ b/phpBB/includes/cron/task/core/prune_forum.php @@ -39,7 +39,7 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p * and a database query will be performed to load the necessary information * about the forum. */ - public function __construct($forum_data=null) + public function __construct($forum_data = null) { global $db; if ($forum_data) -- cgit v1.2.1 From e48b850ab5dfed646e91d87f0dd9c560e7fd76cf Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 29 Oct 2010 13:29:00 +0200 Subject: [feature/system-cron] use phpbb_request instead of plain superglobals PHPBB3-9596 --- phpBB/includes/cron/task/core/prune_forum.php | 13 ++++++------- phpBB/includes/cron/task/parametrized.php | 12 +++++------- 2 files changed, 11 insertions(+), 14 deletions(-) (limited to 'phpBB/includes/cron/task') diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php index 440dc5e358..b3f63c9f6c 100644 --- a/phpBB/includes/cron/task/core/prune_forum.php +++ b/phpBB/includes/cron/task/core/prune_forum.php @@ -103,20 +103,19 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p } /** - * Parses parameters found in $params, which is an array. + * Parses parameters found in $request, which is an instance of + * phpbb_request_interface. * - * $params may contain user input and is not trusted. - * - * $params is expected to have a key f whose value is id of the forum to be pruned. + * It is expected to have a key f whose value is id of the forum to be pruned. */ - public function parse_parameters($params) + public function parse_parameters(phpbb_request_interface $request) { global $db; $this->forum_data = null; - if (isset($params['f'])) + if ($request->is_set('f')) { - $forum_id = (int) $params['f']; + $forum_id = $request->variable('f', 0); $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq FROM ' . FORUMS_TABLE . " diff --git a/phpBB/includes/cron/task/parametrized.php b/phpBB/includes/cron/task/parametrized.php index d505cc3328..a9481250e1 100644 --- a/phpBB/includes/cron/task/parametrized.php +++ b/phpBB/includes/cron/task/parametrized.php @@ -37,13 +37,11 @@ interface phpbb_cron_task_parametrized extends phpbb_cron_task public function get_parameters(); /** - * Parses parameters found in $params, which is an array. + * Parses parameters found in $request, which is an instance of + * phpbb_request_interface. * - * $params contains user input and must not be trusted. - * In normal operation $params contains the same data that was returned by - * get_parameters method. However, a malicious user can supply arbitrary - * data in $params. - * Cron task must validate all keys and values in $params before using them. + * $request contains user input and must not be trusted. + * Cron task must validate all data before using it. */ - public function parse_parameters($params); + public function parse_parameters(phpbb_request_interface $request); } \ No newline at end of file -- cgit v1.2.1 From 4302dab5fa964039d53d14d4a80e7bcd8f5e2db5 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 29 Oct 2010 13:36:11 +0200 Subject: [feature/system-cron] coding guidelines adjustments PHPBB3-9596 --- phpBB/includes/cron/task/core/prune_all_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/cron/task') diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/includes/cron/task/core/prune_all_forums.php index 154409a37c..7159ba6ae3 100644 --- a/phpBB/includes/cron/task/core/prune_all_forums.php +++ b/phpBB/includes/cron/task/core/prune_all_forums.php @@ -33,7 +33,7 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base public function run() { global $phpbb_root_path, $phpEx, $db; - + if (!function_exists('auto_prune')) { include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); -- cgit v1.2.1 From afc538366bc9660f9b7035e48034d1b7dccbd978 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 14 Dec 2010 13:20:54 +0100 Subject: [feature/system-cron] Remove $Id$ from PHP file header PHPBB3-9596 --- phpBB/includes/cron/task/base.php | 1 - phpBB/includes/cron/task/core/prune_all_forums.php | 1 - phpBB/includes/cron/task/core/prune_forum.php | 1 - phpBB/includes/cron/task/core/queue.php | 1 - phpBB/includes/cron/task/core/tidy_cache.php | 1 - phpBB/includes/cron/task/core/tidy_database.php | 1 - phpBB/includes/cron/task/core/tidy_search.php | 1 - phpBB/includes/cron/task/core/tidy_sessions.php | 1 - phpBB/includes/cron/task/core/tidy_warnings.php | 1 - phpBB/includes/cron/task/parametrized.php | 1 - phpBB/includes/cron/task/task.php | 1 - phpBB/includes/cron/task/wrapper.php | 1 - 12 files changed, 12 deletions(-) (limited to 'phpBB/includes/cron/task') diff --git a/phpBB/includes/cron/task/base.php b/phpBB/includes/cron/task/base.php index ba399c18b1..dff98175fb 100644 --- a/phpBB/includes/cron/task/base.php +++ b/phpBB/includes/cron/task/base.php @@ -2,7 +2,6 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/includes/cron/task/core/prune_all_forums.php index 7159ba6ae3..44b04611d5 100644 --- a/phpBB/includes/cron/task/core/prune_all_forums.php +++ b/phpBB/includes/cron/task/core/prune_all_forums.php @@ -2,7 +2,6 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php index b3f63c9f6c..6393281d32 100644 --- a/phpBB/includes/cron/task/core/prune_forum.php +++ b/phpBB/includes/cron/task/core/prune_forum.php @@ -2,7 +2,6 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * diff --git a/phpBB/includes/cron/task/core/queue.php b/phpBB/includes/cron/task/core/queue.php index 271a03937d..852a8d97f4 100644 --- a/phpBB/includes/cron/task/core/queue.php +++ b/phpBB/includes/cron/task/core/queue.php @@ -2,7 +2,6 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * diff --git a/phpBB/includes/cron/task/core/tidy_cache.php b/phpBB/includes/cron/task/core/tidy_cache.php index 9656275742..8a91f68a48 100644 --- a/phpBB/includes/cron/task/core/tidy_cache.php +++ b/phpBB/includes/cron/task/core/tidy_cache.php @@ -2,7 +2,6 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * diff --git a/phpBB/includes/cron/task/core/tidy_database.php b/phpBB/includes/cron/task/core/tidy_database.php index a2a0b84a68..847b882c7d 100644 --- a/phpBB/includes/cron/task/core/tidy_database.php +++ b/phpBB/includes/cron/task/core/tidy_database.php @@ -2,7 +2,6 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * diff --git a/phpBB/includes/cron/task/core/tidy_search.php b/phpBB/includes/cron/task/core/tidy_search.php index dffc44174c..735dc14b68 100644 --- a/phpBB/includes/cron/task/core/tidy_search.php +++ b/phpBB/includes/cron/task/core/tidy_search.php @@ -2,7 +2,6 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * diff --git a/phpBB/includes/cron/task/core/tidy_sessions.php b/phpBB/includes/cron/task/core/tidy_sessions.php index 1d471f9333..dc398fa5e4 100644 --- a/phpBB/includes/cron/task/core/tidy_sessions.php +++ b/phpBB/includes/cron/task/core/tidy_sessions.php @@ -2,7 +2,6 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * diff --git a/phpBB/includes/cron/task/core/tidy_warnings.php b/phpBB/includes/cron/task/core/tidy_warnings.php index 5120369178..c3826dc687 100644 --- a/phpBB/includes/cron/task/core/tidy_warnings.php +++ b/phpBB/includes/cron/task/core/tidy_warnings.php @@ -2,7 +2,6 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * diff --git a/phpBB/includes/cron/task/parametrized.php b/phpBB/includes/cron/task/parametrized.php index a9481250e1..b839904642 100644 --- a/phpBB/includes/cron/task/parametrized.php +++ b/phpBB/includes/cron/task/parametrized.php @@ -2,7 +2,6 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * diff --git a/phpBB/includes/cron/task/task.php b/phpBB/includes/cron/task/task.php index 38fb2a6cd1..050e85c35e 100644 --- a/phpBB/includes/cron/task/task.php +++ b/phpBB/includes/cron/task/task.php @@ -2,7 +2,6 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * diff --git a/phpBB/includes/cron/task/wrapper.php b/phpBB/includes/cron/task/wrapper.php index e31f467cc8..c2e7e42830 100644 --- a/phpBB/includes/cron/task/wrapper.php +++ b/phpBB/includes/cron/task/wrapper.php @@ -2,7 +2,6 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * -- cgit v1.2.1 From 6fc11184e7d2fd2a46d915738ae7f686c8547433 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 16 Dec 2010 02:59:38 +0100 Subject: [feature/system-cron] Adjust SQL query style to follow coding guidelines. PHPBB3-9596 --- phpBB/includes/cron/task/core/prune_all_forums.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/cron/task') diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/includes/cron/task/core/prune_all_forums.php index 44b04611d5..2e6f2444d3 100644 --- a/phpBB/includes/cron/task/core/prune_all_forums.php +++ b/phpBB/includes/cron/task/core/prune_all_forums.php @@ -40,7 +40,8 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq FROM ' . FORUMS_TABLE . " - WHERE enable_prune = 1 and prune_next < " . time(); + WHERE enable_prune = 1 + AND prune_next < " . time(); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { -- cgit v1.2.1 From 47702b8ca72aeaa2b33dd13f2aa762ae7271c10a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 17 Dec 2010 01:24:27 +0100 Subject: [feature/system-cron] Add phpDoc documentation for everything else. PHPBB3-9596 --- phpBB/includes/cron/task/base.php | 6 ++++++ phpBB/includes/cron/task/core/prune_all_forums.php | 4 ++++ phpBB/includes/cron/task/core/prune_forum.php | 13 ++++++++++++- phpBB/includes/cron/task/core/queue.php | 8 ++++++++ phpBB/includes/cron/task/core/tidy_cache.php | 6 ++++++ phpBB/includes/cron/task/core/tidy_database.php | 4 ++++ phpBB/includes/cron/task/core/tidy_search.php | 6 ++++++ phpBB/includes/cron/task/core/tidy_sessions.php | 4 ++++ phpBB/includes/cron/task/core/tidy_warnings.php | 6 ++++++ phpBB/includes/cron/task/parametrized.php | 4 ++++ phpBB/includes/cron/task/task.php | 8 ++++++++ phpBB/includes/cron/task/wrapper.php | 12 ++++++++++++ 12 files changed, 80 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/cron/task') diff --git a/phpBB/includes/cron/task/base.php b/phpBB/includes/cron/task/base.php index dff98175fb..a4e89f137f 100644 --- a/phpBB/includes/cron/task/base.php +++ b/phpBB/includes/cron/task/base.php @@ -33,6 +33,8 @@ abstract class phpbb_cron_task_base implements phpbb_cron_task * * For example, a cron task that prunes forums can only run when * forum pruning is enabled. + * + * @return bool */ public function is_runnable() { @@ -42,6 +44,8 @@ abstract class phpbb_cron_task_base implements phpbb_cron_task /** * Returns whether this cron task should run now, because enough time * has passed since it was last run. + * + * @return bool */ public function should_run() { @@ -50,6 +54,8 @@ abstract class phpbb_cron_task_base implements phpbb_cron_task /** * Returns whether this cron task can be run in shutdown function. + * + * @return bool */ public function is_shutdown_function_safe() { diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/includes/cron/task/core/prune_all_forums.php index 2e6f2444d3..69ae7f63cd 100644 --- a/phpBB/includes/cron/task/core/prune_all_forums.php +++ b/phpBB/includes/cron/task/core/prune_all_forums.php @@ -28,6 +28,8 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base { /** * Runs this cron task. + * + * @return void */ public function run() { @@ -60,6 +62,8 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base /** * Returns whether this cron task can run, given current board configuration. + * + * @return bool */ public function is_runnable() { diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php index 6393281d32..18db44cf2d 100644 --- a/phpBB/includes/cron/task/core/prune_forum.php +++ b/phpBB/includes/cron/task/core/prune_forum.php @@ -37,6 +37,8 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p * If $forum_data is not given, forum id will be retrieved via request_var * and a database query will be performed to load the necessary information * about the forum. + * + * @return void */ public function __construct($forum_data = null) { @@ -53,6 +55,8 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p /** * Runs this cron task. + * + * @return void */ public function run() { @@ -75,6 +79,8 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p /** * Returns whether this cron task can run, given current board configuration. + * + * @return bool */ public function is_runnable() { @@ -85,6 +91,8 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p /** * Returns whether this cron task should run now, because enough time * has passed since it was last run. + * + * @return bool */ public function should_run() { @@ -93,8 +101,9 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p /** * Returns parameters of this cron task as an array. - * * The array has one key, f, whose value is id of the forum to be pruned. + * + * @return array */ public function get_parameters() { @@ -106,6 +115,8 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p * phpbb_request_interface. * * It is expected to have a key f whose value is id of the forum to be pruned. + * + * @return void */ public function parse_parameters(phpbb_request_interface $request) { diff --git a/phpBB/includes/cron/task/core/queue.php b/phpBB/includes/cron/task/core/queue.php index 852a8d97f4..ccea4b85bd 100644 --- a/phpBB/includes/cron/task/core/queue.php +++ b/phpBB/includes/cron/task/core/queue.php @@ -24,6 +24,8 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base { /** * Runs this cron task. + * + * @return void */ public function run() { @@ -38,6 +40,8 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base /** * Returns whether this cron task can run, given current board configuration. + * + * @return bool */ public function is_runnable() { @@ -48,6 +52,8 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base /** * Returns whether this cron task should run now, because enough time * has passed since it was last run. + * + * @return bool */ public function should_run() { @@ -57,6 +63,8 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base /** * Returns whether this cron task can be run in shutdown function. + * + * @return bool */ public function is_shutdown_function_safe() { diff --git a/phpBB/includes/cron/task/core/tidy_cache.php b/phpBB/includes/cron/task/core/tidy_cache.php index 8a91f68a48..83a60d8760 100644 --- a/phpBB/includes/cron/task/core/tidy_cache.php +++ b/phpBB/includes/cron/task/core/tidy_cache.php @@ -24,6 +24,8 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base { /** * Runs this cron task. + * + * @return void */ public function run() { @@ -33,6 +35,8 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base /** * Returns whether this cron task can run, given current board configuration. + * + * @return bool */ public function is_runnable() { @@ -43,6 +47,8 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base /** * Returns whether this cron task should run now, because enough time * has passed since it was last run. + * + * @return bool */ public function should_run() { diff --git a/phpBB/includes/cron/task/core/tidy_database.php b/phpBB/includes/cron/task/core/tidy_database.php index 847b882c7d..82a0a4583e 100644 --- a/phpBB/includes/cron/task/core/tidy_database.php +++ b/phpBB/includes/cron/task/core/tidy_database.php @@ -24,6 +24,8 @@ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base { /** * Runs this cron task. + * + * @return void */ public function run() { @@ -38,6 +40,8 @@ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base /** * Returns whether this cron task should run now, because enough time * has passed since it was last run. + * + * @return bool */ public function should_run() { diff --git a/phpBB/includes/cron/task/core/tidy_search.php b/phpBB/includes/cron/task/core/tidy_search.php index 735dc14b68..a781005960 100644 --- a/phpBB/includes/cron/task/core/tidy_search.php +++ b/phpBB/includes/cron/task/core/tidy_search.php @@ -26,6 +26,8 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base { /** * Runs this cron task. + * + * @return void */ public function run() { @@ -51,6 +53,8 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base /** * Returns whether this cron task can run, given current board configuration. + * + * @return bool */ public function is_runnable() { @@ -65,6 +69,8 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base /** * Returns whether this cron task should run now, because enough time * has passed since it was last run. + * + * @return bool */ public function should_run() { diff --git a/phpBB/includes/cron/task/core/tidy_sessions.php b/phpBB/includes/cron/task/core/tidy_sessions.php index dc398fa5e4..5826584691 100644 --- a/phpBB/includes/cron/task/core/tidy_sessions.php +++ b/phpBB/includes/cron/task/core/tidy_sessions.php @@ -24,6 +24,8 @@ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base { /** * Runs this cron task. + * + * @return void */ public function run() { @@ -34,6 +36,8 @@ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base /** * Returns whether this cron task should run now, because enough time * has passed since it was last run. + * + * @return bool */ public function should_run() { diff --git a/phpBB/includes/cron/task/core/tidy_warnings.php b/phpBB/includes/cron/task/core/tidy_warnings.php index c3826dc687..3b0cf57f0c 100644 --- a/phpBB/includes/cron/task/core/tidy_warnings.php +++ b/phpBB/includes/cron/task/core/tidy_warnings.php @@ -26,6 +26,8 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base { /** * Runs this cron task. + * + * @return void */ public function run() { @@ -39,6 +41,8 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base /** * Returns whether this cron task can run, given current board configuration. + * + * @return bool */ public function is_runnable() { @@ -49,6 +53,8 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base /** * Returns whether this cron task should run now, because enough time * has passed since it was last run. + * + * @return bool */ public function should_run() { diff --git a/phpBB/includes/cron/task/parametrized.php b/phpBB/includes/cron/task/parametrized.php index b839904642..6f87e1c818 100644 --- a/phpBB/includes/cron/task/parametrized.php +++ b/phpBB/includes/cron/task/parametrized.php @@ -32,6 +32,8 @@ interface phpbb_cron_task_parametrized extends phpbb_cron_task * Returns parameters of this cron task as an array. * * The array must map string keys to string values. + * + * @return array */ public function get_parameters(); @@ -41,6 +43,8 @@ interface phpbb_cron_task_parametrized extends phpbb_cron_task * * $request contains user input and must not be trusted. * Cron task must validate all data before using it. + * + * @return void */ public function parse_parameters(phpbb_request_interface $request); } \ No newline at end of file diff --git a/phpBB/includes/cron/task/task.php b/phpBB/includes/cron/task/task.php index 050e85c35e..72fda91dd0 100644 --- a/phpBB/includes/cron/task/task.php +++ b/phpBB/includes/cron/task/task.php @@ -23,6 +23,8 @@ interface phpbb_cron_task { /** * Runs this cron task. + * + * @return void */ public function run(); @@ -31,17 +33,23 @@ interface phpbb_cron_task * * For example, a cron task that prunes forums can only run when * forum pruning is enabled. + * + * @return bool */ public function is_runnable(); /** * Returns whether this cron task should run now, because enough time * has passed since it was last run. + * + * @return bool */ public function should_run(); /** * Returns whether this cron task can be run in shutdown function. + * + * @return bool */ public function is_shutdown_function_safe(); } diff --git a/phpBB/includes/cron/task/wrapper.php b/phpBB/includes/cron/task/wrapper.php index c2e7e42830..23cd4de724 100644 --- a/phpBB/includes/cron/task/wrapper.php +++ b/phpBB/includes/cron/task/wrapper.php @@ -25,6 +25,8 @@ class phpbb_cron_task_wrapper { /** * Wraps a task $task, which must implement cron_task interface. + * + * @return void */ public function __construct(phpbb_cron_task $task) { @@ -36,6 +38,8 @@ class phpbb_cron_task_wrapper * * Parametrized tasks accept parameters during initialization and must * normally be scheduled with parameters. + * + * @return bool Whether or not this task is parametrized. */ public function is_parametrized() { @@ -47,6 +51,8 @@ class phpbb_cron_task_wrapper * * A task is ready to run when it is runnable according to current configuration * and enough time has passed since it was last run. + * + * @return bool Whether the wrapped task is ready to run. */ public function is_ready() { @@ -55,6 +61,8 @@ class phpbb_cron_task_wrapper /** * Returns the name of wrapped task. It is the same as the wrapped class's class name. + * + * @return string Class name of wrapped task. */ public function get_name() { @@ -63,6 +71,8 @@ class phpbb_cron_task_wrapper /** * Returns a url through which this task may be invoked via web. + * + * @return string URL */ public function get_url() { @@ -88,6 +98,8 @@ class phpbb_cron_task_wrapper /** * Forwards all other method calls to the wrapped task implementation. + * + * @return mixed */ public function __call($name, $args) { -- cgit v1.2.1 From 53dd847dd582930c84518d77a805468543e32ad0 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 19 Dec 2010 23:56:43 +0100 Subject: [feature/system-cron] Added @param/@return documentation Also adjusted some function descriptions for greater informativity. PHPBB3-9596 --- phpBB/includes/cron/task/base.php | 11 ++++++++++- phpBB/includes/cron/task/core/prune_all_forums.php | 2 ++ phpBB/includes/cron/task/core/prune_forum.php | 12 +++++++++++- phpBB/includes/cron/task/core/queue.php | 9 +++++++++ phpBB/includes/cron/task/core/tidy_cache.php | 6 ++++++ phpBB/includes/cron/task/core/tidy_database.php | 3 +++ phpBB/includes/cron/task/core/tidy_search.php | 7 +++++++ phpBB/includes/cron/task/core/tidy_sessions.php | 3 +++ phpBB/includes/cron/task/core/tidy_warnings.php | 5 +++++ phpBB/includes/cron/task/parametrized.php | 4 +++- phpBB/includes/cron/task/task.php | 9 +++++++++ phpBB/includes/cron/task/wrapper.php | 12 +++++++++--- 12 files changed, 77 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/cron/task') diff --git a/phpBB/includes/cron/task/base.php b/phpBB/includes/cron/task/base.php index a4e89f137f..38c0b844d9 100644 --- a/phpBB/includes/cron/task/base.php +++ b/phpBB/includes/cron/task/base.php @@ -55,7 +55,16 @@ abstract class phpbb_cron_task_base implements phpbb_cron_task /** * Returns whether this cron task can be run in shutdown function. * - * @return bool + * By the time shutdown sequence invokes a particular piece of code, + * resources that that code requires may already be released. + * If so, a particular cron task may be marked shutdown function- + * unsafe, and it will be executed in normal program flow. + * + * Generally speaking cron tasks should start off as shutdown function- + * safe, and only be marked shutdown function-unsafe if a problem + * is discovered. + * + * @return bool Whether the cron task is shutdown function-safe. */ public function is_shutdown_function_safe() { diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/includes/cron/task/core/prune_all_forums.php index 69ae7f63cd..39b5765229 100644 --- a/phpBB/includes/cron/task/core/prune_all_forums.php +++ b/phpBB/includes/cron/task/core/prune_all_forums.php @@ -63,6 +63,8 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base /** * Returns whether this cron task can run, given current board configuration. * + * This cron task will only run when system cron is utilised. + * * @return bool */ public function is_runnable() diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php index 18db44cf2d..55b1c58cd4 100644 --- a/phpBB/includes/cron/task/core/prune_forum.php +++ b/phpBB/includes/cron/task/core/prune_forum.php @@ -38,7 +38,7 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p * and a database query will be performed to load the necessary information * about the forum. * - * @return void + * @param array $forum_data Information about a forum to be pruned. */ public function __construct($forum_data = null) { @@ -80,6 +80,12 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p /** * Returns whether this cron task can run, given current board configuration. * + * This cron task will not run when system cron is utilised, as in + * such cases prune_all_forums task would run instead. + * + * Additionally, this task must be given the forum data, either via + * the constructor or parse_parameters method. + * * @return bool */ public function is_runnable() @@ -92,6 +98,8 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p * Returns whether this cron task should run now, because enough time * has passed since it was last run. * + * Forum pruning interval is specified in the forum data. + * * @return bool */ public function should_run() @@ -116,6 +124,8 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p * * It is expected to have a key f whose value is id of the forum to be pruned. * + * @param phpbb_request_interface $request Request object. + * * @return void */ public function parse_parameters(phpbb_request_interface $request) diff --git a/phpBB/includes/cron/task/core/queue.php b/phpBB/includes/cron/task/core/queue.php index ccea4b85bd..0e9de05984 100644 --- a/phpBB/includes/cron/task/core/queue.php +++ b/phpBB/includes/cron/task/core/queue.php @@ -41,6 +41,8 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base /** * Returns whether this cron task can run, given current board configuration. * + * Queue task is only run if the email queue (file) exists. + * * @return bool */ public function is_runnable() @@ -53,6 +55,8 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base * Returns whether this cron task should run now, because enough time * has passed since it was last run. * + * The interval between queue runs is specified in board configuration. + * * @return bool */ public function should_run() @@ -64,6 +68,11 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base /** * Returns whether this cron task can be run in shutdown function. * + * A user reported that using the mail() function during shutdown + * function execution does not work. Therefore if email is delivered + * via the mail() function (as opposed to SMTP) queue cron task marks + * itself shutdown function-unsafe. + * * @return bool */ public function is_shutdown_function_safe() diff --git a/phpBB/includes/cron/task/core/tidy_cache.php b/phpBB/includes/cron/task/core/tidy_cache.php index 83a60d8760..793ce746b4 100644 --- a/phpBB/includes/cron/task/core/tidy_cache.php +++ b/phpBB/includes/cron/task/core/tidy_cache.php @@ -36,6 +36,9 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base /** * Returns whether this cron task can run, given current board configuration. * + * Tidy cache cron task runs if the cache implementation in use + * supports tidying. + * * @return bool */ public function is_runnable() @@ -48,6 +51,9 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base * Returns whether this cron task should run now, because enough time * has passed since it was last run. * + * The interval between cache tidying is specified in board + * configuration. + * * @return bool */ public function should_run() diff --git a/phpBB/includes/cron/task/core/tidy_database.php b/phpBB/includes/cron/task/core/tidy_database.php index 82a0a4583e..fb0e81eaba 100644 --- a/phpBB/includes/cron/task/core/tidy_database.php +++ b/phpBB/includes/cron/task/core/tidy_database.php @@ -41,6 +41,9 @@ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base * Returns whether this cron task should run now, because enough time * has passed since it was last run. * + * The interval between database tidying is specified in board + * configuration. + * * @return bool */ public function should_run() diff --git a/phpBB/includes/cron/task/core/tidy_search.php b/phpBB/includes/cron/task/core/tidy_search.php index a781005960..dcc78abbb8 100644 --- a/phpBB/includes/cron/task/core/tidy_search.php +++ b/phpBB/includes/cron/task/core/tidy_search.php @@ -54,6 +54,10 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base /** * Returns whether this cron task can run, given current board configuration. * + * Search cron task is runnable in all normal use. It may not be + * runnable if the search backend implementation selected in board + * configuration does not exist. + * * @return bool */ public function is_runnable() @@ -70,6 +74,9 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base * Returns whether this cron task should run now, because enough time * has passed since it was last run. * + * The interval between search tidying is specified in board + * configuration. + * * @return bool */ public function should_run() diff --git a/phpBB/includes/cron/task/core/tidy_sessions.php b/phpBB/includes/cron/task/core/tidy_sessions.php index 5826584691..81e7e6a147 100644 --- a/phpBB/includes/cron/task/core/tidy_sessions.php +++ b/phpBB/includes/cron/task/core/tidy_sessions.php @@ -37,6 +37,9 @@ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base * Returns whether this cron task should run now, because enough time * has passed since it was last run. * + * The interval between session tidying is specified in board + * configuration. + * * @return bool */ public function should_run() diff --git a/phpBB/includes/cron/task/core/tidy_warnings.php b/phpBB/includes/cron/task/core/tidy_warnings.php index 3b0cf57f0c..e7d4cc9eea 100644 --- a/phpBB/includes/cron/task/core/tidy_warnings.php +++ b/phpBB/includes/cron/task/core/tidy_warnings.php @@ -42,6 +42,8 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base /** * Returns whether this cron task can run, given current board configuration. * + * If warnings are set to never expire, this cron task will not run. + * * @return bool */ public function is_runnable() @@ -54,6 +56,9 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base * Returns whether this cron task should run now, because enough time * has passed since it was last run. * + * The interval between warnings tidying is specified in board + * configuration. + * * @return bool */ public function should_run() diff --git a/phpBB/includes/cron/task/parametrized.php b/phpBB/includes/cron/task/parametrized.php index 6f87e1c818..c6c45be0c0 100644 --- a/phpBB/includes/cron/task/parametrized.php +++ b/phpBB/includes/cron/task/parametrized.php @@ -44,7 +44,9 @@ interface phpbb_cron_task_parametrized extends phpbb_cron_task * $request contains user input and must not be trusted. * Cron task must validate all data before using it. * + * @param phpbb_request_interface $request Request object. + * * @return void */ public function parse_parameters(phpbb_request_interface $request); -} \ No newline at end of file +} diff --git a/phpBB/includes/cron/task/task.php b/phpBB/includes/cron/task/task.php index 72fda91dd0..58c4a96f8e 100644 --- a/phpBB/includes/cron/task/task.php +++ b/phpBB/includes/cron/task/task.php @@ -49,6 +49,15 @@ interface phpbb_cron_task /** * Returns whether this cron task can be run in shutdown function. * + * By the time shutdown sequence invokes a particular piece of code, + * resources that that code requires may already be released. + * If so, a particular cron task may be marked shutdown function- + * unsafe, and it will be executed in normal program flow. + * + * Generally speaking cron tasks should start off as shutdown function- + * safe, and only be marked shutdown function-unsafe if a problem + * is discovered. + * * @return bool */ public function is_shutdown_function_safe(); diff --git a/phpBB/includes/cron/task/wrapper.php b/phpBB/includes/cron/task/wrapper.php index 23cd4de724..238d97853c 100644 --- a/phpBB/includes/cron/task/wrapper.php +++ b/phpBB/includes/cron/task/wrapper.php @@ -24,9 +24,11 @@ if (!defined('IN_PHPBB')) class phpbb_cron_task_wrapper { /** + * Constructor. + * * Wraps a task $task, which must implement cron_task interface. * - * @return void + * @param phpbb_cron_task $task The cron task to wrap. */ public function __construct(phpbb_cron_task $task) { @@ -34,7 +36,7 @@ class phpbb_cron_task_wrapper } /** - * Returns whether this task is parametrized. + * Returns whether the wrapped task is parametrised. * * Parametrized tasks accept parameters during initialization and must * normally be scheduled with parameters. @@ -72,7 +74,11 @@ class phpbb_cron_task_wrapper /** * Returns a url through which this task may be invoked via web. * - * @return string URL + * When system cron is not in use, running a cron task is accomplished + * by outputting an image with the url returned by this function as + * source. + * + * @return string URL through which this task may be invoked. */ public function get_url() { -- cgit v1.2.1