From 7030578bbe9e11c18b5becaf8b06e670e3c2e3cd Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 01:32:34 -0400 Subject: [ticket/11698] Moving all autoloadable files to phpbb/ PHPBB3-11698 --- phpBB/phpbb/cron/task/wrapper.php | 108 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 phpBB/phpbb/cron/task/wrapper.php (limited to 'phpBB/phpbb/cron/task/wrapper.php') diff --git a/phpBB/phpbb/cron/task/wrapper.php b/phpBB/phpbb/cron/task/wrapper.php new file mode 100644 index 0000000000..386fb5b383 --- /dev/null +++ b/phpBB/phpbb/cron/task/wrapper.php @@ -0,0 +1,108 @@ +task = $task; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + } + + /** + * Returns whether the wrapped task is parametrised. + * + * 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() + { + 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. + * + * @return bool Whether the wrapped task is ready to run. + */ + public function is_ready() + { + return $this->task->is_runnable() && $this->task->should_run(); + } + + /** + * Returns a url through which this task may be invoked via web. + * + * 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() + { + $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($this->phpbb_root_path . 'cron.' . $this->php_ext, 'cron_type=' . $name . $extra); + return $url; + } + + /** + * Forwards all other method calls to the wrapped task implementation. + * + * @return mixed + */ + public function __call($name, $args) + { + return call_user_func_array(array($this->task, $name), $args); + } +} -- cgit v1.2.1 From b95fdacdd378877d277e261465da73deb06e50da Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 14:01:09 +0200 Subject: [ticket/11700] Move all recent code to namespaces PHPBB3-11700 --- phpBB/phpbb/cron/task/wrapper.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/cron/task/wrapper.php') diff --git a/phpBB/phpbb/cron/task/wrapper.php b/phpBB/phpbb/cron/task/wrapper.php index 386fb5b383..aa015966c6 100644 --- a/phpBB/phpbb/cron/task/wrapper.php +++ b/phpBB/phpbb/cron/task/wrapper.php @@ -7,6 +7,8 @@ * */ +namespace phpbb\cron\task; + /** * @ignore */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class phpbb_cron_task_wrapper +class wrapper { protected $task; protected $phpbb_root_path; @@ -32,9 +34,9 @@ class phpbb_cron_task_wrapper * * Wraps a task $task, which must implement cron_task interface. * - * @param phpbb_cron_task $task The cron task to wrap. + * @param \phpbb\cron\task\task $task The cron task to wrap. */ - public function __construct(phpbb_cron_task $task, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\cron\task\task $task, $phpbb_root_path, $php_ext) { $this->task = $task; $this->phpbb_root_path = $phpbb_root_path; @@ -51,7 +53,7 @@ class phpbb_cron_task_wrapper */ public function is_parametrized() { - return $this->task instanceof phpbb_cron_task_parametrized; + return $this->task instanceof \phpbb\cron\task\parametrized; } /** -- cgit v1.2.1 From 7aa8f6461f1e85cf91931f56b95384e54fec07c2 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 30 Oct 2013 13:05:28 +0100 Subject: [task/code-sniffer] Remove the IN_PHPBB check side-effect from class files. PHPBB3-11980 --- phpBB/phpbb/cron/task/wrapper.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'phpBB/phpbb/cron/task/wrapper.php') diff --git a/phpBB/phpbb/cron/task/wrapper.php b/phpBB/phpbb/cron/task/wrapper.php index aa015966c6..fc3f897206 100644 --- a/phpBB/phpbb/cron/task/wrapper.php +++ b/phpBB/phpbb/cron/task/wrapper.php @@ -9,14 +9,6 @@ namespace phpbb\cron\task; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - /** * Cron task wrapper class. * Enhances cron tasks with convenience methods that work identically for all tasks. -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- phpBB/phpbb/cron/task/wrapper.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/cron/task/wrapper.php') diff --git a/phpBB/phpbb/cron/task/wrapper.php b/phpBB/phpbb/cron/task/wrapper.php index fc3f897206..11399282d3 100644 --- a/phpBB/phpbb/cron/task/wrapper.php +++ b/phpBB/phpbb/cron/task/wrapper.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ @@ -12,8 +16,6 @@ namespace phpbb\cron\task; /** * Cron task wrapper class. * Enhances cron tasks with convenience methods that work identically for all tasks. -* -* @package phpBB3 */ class wrapper { -- cgit v1.2.1 From 8f2395857e785cf8b7ccb338937b7cd30b329aab Mon Sep 17 00:00:00 2001 From: n-aleha Date: Mon, 19 May 2014 04:07:08 +0300 Subject: [ticket/12557] Search, cron and profilefields fixes PHPBB3-12557 --- phpBB/phpbb/cron/task/wrapper.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/phpbb/cron/task/wrapper.php') diff --git a/phpBB/phpbb/cron/task/wrapper.php b/phpBB/phpbb/cron/task/wrapper.php index 11399282d3..7035a11515 100644 --- a/phpBB/phpbb/cron/task/wrapper.php +++ b/phpBB/phpbb/cron/task/wrapper.php @@ -29,6 +29,8 @@ class wrapper * Wraps a task $task, which must implement cron_task interface. * * @param \phpbb\cron\task\task $task The cron task to wrap. + * @param string $phpbb_root_path Relative path to phpBB root + * @param string $php_ext PHP extension (php) */ public function __construct(\phpbb\cron\task\task $task, $phpbb_root_path, $php_ext) { -- cgit v1.2.1 From 80067467805d4b1664777cf3553c39fc32cfdb65 Mon Sep 17 00:00:00 2001 From: n-aleha Date: Thu, 7 Aug 2014 13:19:49 +0300 Subject: [ticket/12557] Fix php file description PHPBB3-12557 --- phpBB/phpbb/cron/task/wrapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/cron/task/wrapper.php') diff --git a/phpBB/phpbb/cron/task/wrapper.php b/phpBB/phpbb/cron/task/wrapper.php index 7035a11515..8a4a8b1f0c 100644 --- a/phpBB/phpbb/cron/task/wrapper.php +++ b/phpBB/phpbb/cron/task/wrapper.php @@ -30,7 +30,7 @@ class wrapper * * @param \phpbb\cron\task\task $task The cron task to wrap. * @param string $phpbb_root_path Relative path to phpBB root - * @param string $php_ext PHP extension (php) + * @param string $php_ext PHP file extension */ public function __construct(\phpbb\cron\task\task $task, $phpbb_root_path, $php_ext) { -- cgit v1.2.1