aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/cron
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-09-27 10:47:10 +0200
committerMarc Alexander <admin@m-a-styles.de>2013-09-27 10:47:10 +0200
commit663b4b2eb74e8edb076c962662ff5124e94353ea (patch)
tree0ff449c776397b2b66fc7d567f93bbb7d62ea2e3 /phpBB/phpbb/cron
parent01512104b5823d15eed64d362b41b9594f870f0c (diff)
parent8db820be634cfce0fdb079fdbaee2c49661a7870 (diff)
downloadforums-663b4b2eb74e8edb076c962662ff5124e94353ea.tar
forums-663b4b2eb74e8edb076c962662ff5124e94353ea.tar.gz
forums-663b4b2eb74e8edb076c962662ff5124e94353ea.tar.bz2
forums-663b4b2eb74e8edb076c962662ff5124e94353ea.tar.xz
forums-663b4b2eb74e8edb076c962662ff5124e94353ea.zip
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into feature/passwords
Conflicts: phpBB/develop/create_schema_files.php
Diffstat (limited to 'phpBB/phpbb/cron')
-rw-r--r--phpBB/phpbb/cron/manager.php24
-rw-r--r--phpBB/phpbb/cron/task/base.php4
-rw-r--r--phpBB/phpbb/cron/task/core/prune_all_forums.php10
-rw-r--r--phpBB/phpbb/cron/task/core/prune_forum.php16
-rw-r--r--phpBB/phpbb/cron/task/core/prune_notifications.php65
-rw-r--r--phpBB/phpbb/cron/task/core/queue.php10
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_cache.php10
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_database.php8
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_search.php14
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_sessions.php10
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_warnings.php8
-rw-r--r--phpBB/phpbb/cron/task/parametrized.php10
-rw-r--r--phpBB/phpbb/cron/task/task.php4
-rw-r--r--phpBB/phpbb/cron/task/wrapper.php10
14 files changed, 147 insertions, 56 deletions
diff --git a/phpBB/phpbb/cron/manager.php b/phpBB/phpbb/cron/manager.php
index 84c9650830..f58ba64a3d 100644
--- a/phpBB/phpbb/cron/manager.php
+++ b/phpBB/phpbb/cron/manager.php
@@ -7,6 +7,8 @@
*
*/
+namespace phpbb\cron;
+
/**
* @ignore
*/
@@ -22,10 +24,10 @@ if (!defined('IN_PHPBB'))
*
* @package phpBB3
*/
-class phpbb_cron_manager
+class manager
{
/**
- * Set of phpbb_cron_task_wrapper objects.
+ * Set of \phpbb\cron\task\wrapper objects.
* Array holding all tasks that have been found.
*
* @var array
@@ -52,7 +54,7 @@ class phpbb_cron_manager
* Loads tasks given by name, wraps them
* and puts them into $this->tasks.
*
- * @param array|Traversable $tasks Array of instances of phpbb_cron_task
+ * @param array|Traversable $tasks Array of instances of \phpbb\cron\task\task
*
* @return null
*/
@@ -71,7 +73,7 @@ class phpbb_cron_manager
*
* If no tasks are ready, null is returned.
*
- * @return phpbb_cron_task_wrapper|null
+ * @return \phpbb\cron\task\wrapper|null
*/
public function find_one_ready_task()
{
@@ -88,7 +90,7 @@ class phpbb_cron_manager
/**
* Finds all tasks that are ready to run.
*
- * @return array List of tasks which are ready to run (wrapped in phpbb_cron_task_wrapper).
+ * @return array List of tasks which are ready to run (wrapped in \phpbb\cron\task\wrapper).
*/
public function find_all_ready_tasks()
{
@@ -111,7 +113,7 @@ class phpbb_cron_manager
* Web runner uses this method to resolve names to tasks.
*
* @param string $name Name of the task to look up.
- * @return phpbb_cron_task A task corresponding to the given name, or null.
+ * @return \phpbb\cron\task\task A task corresponding to the given name, or null.
*/
public function find_task($name)
{
@@ -126,13 +128,13 @@ class phpbb_cron_manager
}
/**
- * Wraps a task inside an instance of phpbb_cron_task_wrapper.
+ * Wraps a task inside an instance of \phpbb\cron\task\wrapper.
*
- * @param phpbb_cron_task $task The task.
- * @return phpbb_cron_task_wrapper The wrapped task.
+ * @param \phpbb\cron\task\task $task The task.
+ * @return \phpbb\cron\task\wrapper The wrapped task.
*/
- public function wrap_task(phpbb_cron_task $task)
+ public function wrap_task(\phpbb\cron\task\task $task)
{
- return new phpbb_cron_task_wrapper($task, $this->phpbb_root_path, $this->php_ext);
+ return new \phpbb\cron\task\wrapper($task, $this->phpbb_root_path, $this->php_ext);
}
}
diff --git a/phpBB/phpbb/cron/task/base.php b/phpBB/phpbb/cron/task/base.php
index 94a2f267b4..f30c9daf1b 100644
--- a/phpBB/phpbb/cron/task/base.php
+++ b/phpBB/phpbb/cron/task/base.php
@@ -7,6 +7,8 @@
*
*/
+namespace phpbb\cron\task;
+
/**
* @ignore
*/
@@ -26,7 +28,7 @@ if (!defined('IN_PHPBB'))
*
* @package phpBB3
*/
-abstract class phpbb_cron_task_base implements phpbb_cron_task
+abstract class base implements \phpbb\cron\task\task
{
private $name;
diff --git a/phpBB/phpbb/cron/task/core/prune_all_forums.php b/phpBB/phpbb/cron/task/core/prune_all_forums.php
index 2c5d38cec0..8e3ef25ce6 100644
--- a/phpBB/phpbb/cron/task/core/prune_all_forums.php
+++ b/phpBB/phpbb/cron/task/core/prune_all_forums.php
@@ -7,6 +7,8 @@
*
*/
+namespace phpbb\cron\task\core;
+
/**
* @ignore
*/
@@ -24,7 +26,7 @@ if (!defined('IN_PHPBB'))
*
* @package phpBB3
*/
-class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base
+class prune_all_forums extends \phpbb\cron\task\base
{
protected $phpbb_root_path;
protected $php_ext;
@@ -36,10 +38,10 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base
*
* @param string $phpbb_root_path The root path
* @param string $php_ext The PHP extension
- * @param phpbb_config $config The config
- * @param phpbb_db_driver $db The db connection
+ * @param \phpbb\config\config $config The config
+ * @param \phpbb\db\driver\driver $db The db connection
*/
- public function __construct($phpbb_root_path, $php_ext, phpbb_config $config, phpbb_db_driver $db)
+ public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver $db)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
diff --git a/phpBB/phpbb/cron/task/core/prune_forum.php b/phpBB/phpbb/cron/task/core/prune_forum.php
index e3c497f072..f14ab7b702 100644
--- a/phpBB/phpbb/cron/task/core/prune_forum.php
+++ b/phpBB/phpbb/cron/task/core/prune_forum.php
@@ -7,6 +7,8 @@
*
*/
+namespace phpbb\cron\task\core;
+
/**
* @ignore
*/
@@ -24,7 +26,7 @@ if (!defined('IN_PHPBB'))
*
* @package phpBB3
*/
-class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements phpbb_cron_task_parametrized
+class prune_forum extends \phpbb\cron\task\base implements \phpbb\cron\task\parametrized
{
protected $phpbb_root_path;
protected $php_ext;
@@ -46,10 +48,10 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p
*
* @param string $phpbb_root_path The root path
* @param string $php_ext The PHP extension
- * @param phpbb_config $config The config
- * @param phpbb_db_driver $db The db connection
+ * @param \phpbb\config\config $config The config
+ * @param \phpbb\db\driver\driver $db The db connection
*/
- public function __construct($phpbb_root_path, $php_ext, phpbb_config $config, phpbb_db_driver $db)
+ public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver $db)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
@@ -132,15 +134,15 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p
/**
* Parses parameters found in $request, which is an instance of
- * phpbb_request_interface.
+ * \phpbb\request\request_interface.
*
* 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.
+ * @param \phpbb\request\request_interface $request Request object.
*
* @return null
*/
- public function parse_parameters(phpbb_request_interface $request)
+ public function parse_parameters(\phpbb\request\request_interface $request)
{
$this->forum_data = null;
if ($request->is_set('f'))
diff --git a/phpBB/phpbb/cron/task/core/prune_notifications.php b/phpBB/phpbb/cron/task/core/prune_notifications.php
new file mode 100644
index 0000000000..296c0ae64f
--- /dev/null
+++ b/phpBB/phpbb/cron/task/core/prune_notifications.php
@@ -0,0 +1,65 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* Prune notifications cron task.
+*
+* @package phpBB3
+*/
+class phpbb_cron_task_core_prune_notifications extends phpbb_cron_task_base
+{
+ protected $config;
+ protected $notification_manager;
+
+ /**
+ * Constructor.
+ *
+ * @param phpbb_config $config The config
+ * @param phpbb_notification_manager $notification_manager Notification manager
+ */
+ public function __construct(phpbb_config $config, phpbb_notification_manager $notification_manager)
+ {
+ $this->config = $config;
+ $this->notification_manager = $notification_manager;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function run()
+ {
+ // time minus expire days in seconds
+ $timestamp = time() - ($this->config['read_notification_expire_days'] * 60 * 60 * 24);
+ $this->notification_manager->prune_notifications($timestamp);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function is_runnable()
+ {
+ return (bool) $this->config['read_notification_expire_days'];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function should_run()
+ {
+ return $this->config['read_notification_last_gc'] < time() - $this->config['read_notification_gc'];
+ }
+}
diff --git a/phpBB/phpbb/cron/task/core/queue.php b/phpBB/phpbb/cron/task/core/queue.php
index 732f9c6bea..cb13df86df 100644
--- a/phpBB/phpbb/cron/task/core/queue.php
+++ b/phpBB/phpbb/cron/task/core/queue.php
@@ -7,6 +7,8 @@
*
*/
+namespace phpbb\cron\task\core;
+
/**
* @ignore
*/
@@ -20,7 +22,7 @@ if (!defined('IN_PHPBB'))
*
* @package phpBB3
*/
-class phpbb_cron_task_core_queue extends phpbb_cron_task_base
+class queue extends \phpbb\cron\task\base
{
protected $phpbb_root_path;
protected $php_ext;
@@ -31,9 +33,9 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base
*
* @param string $phpbb_root_path The root path
* @param string $php_ext The PHP extension
- * @param phpbb_config $config The config
+ * @param \phpbb\config\config $config The config
*/
- public function __construct($phpbb_root_path, $php_ext, phpbb_config $config)
+ public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
@@ -51,7 +53,7 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base
{
include($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);
}
- $queue = new queue();
+ $queue = new \queue();
$queue->process();
}
diff --git a/phpBB/phpbb/cron/task/core/tidy_cache.php b/phpBB/phpbb/cron/task/core/tidy_cache.php
index 16a45dae7c..021d5fd8a3 100644
--- a/phpBB/phpbb/cron/task/core/tidy_cache.php
+++ b/phpBB/phpbb/cron/task/core/tidy_cache.php
@@ -7,6 +7,8 @@
*
*/
+namespace phpbb\cron\task\core;
+
/**
* @ignore
*/
@@ -20,7 +22,7 @@ if (!defined('IN_PHPBB'))
*
* @package phpBB3
*/
-class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base
+class tidy_cache extends \phpbb\cron\task\base
{
protected $config;
protected $cache;
@@ -28,10 +30,10 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base
/**
* Constructor.
*
- * @param phpbb_config $config The config
- * @param phpbb_cache_driver_interface $cache The cache driver
+ * @param \phpbb\config\config $config The config
+ * @param \phpbb\cache\driver\driver_interface $cache The cache driver
*/
- public function __construct(phpbb_config $config, phpbb_cache_driver_interface $cache)
+ public function __construct(\phpbb\config\config $config, \phpbb\cache\driver\driver_interface $cache)
{
$this->config = $config;
$this->cache = $cache;
diff --git a/phpBB/phpbb/cron/task/core/tidy_database.php b/phpBB/phpbb/cron/task/core/tidy_database.php
index b882e7b500..d03cba1d86 100644
--- a/phpBB/phpbb/cron/task/core/tidy_database.php
+++ b/phpBB/phpbb/cron/task/core/tidy_database.php
@@ -7,6 +7,8 @@
*
*/
+namespace phpbb\cron\task\core;
+
/**
* @ignore
*/
@@ -20,7 +22,7 @@ if (!defined('IN_PHPBB'))
*
* @package phpBB3
*/
-class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base
+class tidy_database extends \phpbb\cron\task\base
{
protected $phpbb_root_path;
protected $php_ext;
@@ -31,9 +33,9 @@ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base
*
* @param string $phpbb_root_path The root path
* @param string $php_ext The PHP extension
- * @param phpbb_config $config The config
+ * @param \phpbb\config\config $config The config
*/
- public function __construct($phpbb_root_path, $php_ext, phpbb_config $config)
+ public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
diff --git a/phpBB/phpbb/cron/task/core/tidy_search.php b/phpBB/phpbb/cron/task/core/tidy_search.php
index a3d5b7dbd2..ebd0d86cbc 100644
--- a/phpBB/phpbb/cron/task/core/tidy_search.php
+++ b/phpBB/phpbb/cron/task/core/tidy_search.php
@@ -7,6 +7,8 @@
*
*/
+namespace phpbb\cron\task\core;
+
/**
* @ignore
*/
@@ -22,7 +24,7 @@ if (!defined('IN_PHPBB'))
*
* @package phpBB3
*/
-class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base
+class tidy_search extends \phpbb\cron\task\base
{
protected $phpbb_root_path;
protected $php_ext;
@@ -36,12 +38,12 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base
*
* @param string $phpbb_root_path The root path
* @param string $php_ext The PHP extension
- * @param phpbb_auth $auth The auth
- * @param phpbb_config $config The config
- * @param phpbb_db_driver $db The db connection
- * @param phpbb_user $user The user
+ * @param \phpbb\auth\auth $auth The auth
+ * @param \phpbb\config\config $config The config
+ * @param \phpbb\db\driver\driver $db The db connection
+ * @param \phpbb\user $user The user
*/
- public function __construct($phpbb_root_path, $php_ext, phpbb_auth $auth, phpbb_config $config, phpbb_db_driver $db, phpbb_user $user)
+ public function __construct($phpbb_root_path, $php_ext, \phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver $db, \phpbb\user $user)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
diff --git a/phpBB/phpbb/cron/task/core/tidy_sessions.php b/phpBB/phpbb/cron/task/core/tidy_sessions.php
index 95f55235c9..5df019ae46 100644
--- a/phpBB/phpbb/cron/task/core/tidy_sessions.php
+++ b/phpBB/phpbb/cron/task/core/tidy_sessions.php
@@ -7,6 +7,8 @@
*
*/
+namespace phpbb\cron\task\core;
+
/**
* @ignore
*/
@@ -20,7 +22,7 @@ if (!defined('IN_PHPBB'))
*
* @package phpBB3
*/
-class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base
+class tidy_sessions extends \phpbb\cron\task\base
{
protected $config;
protected $user;
@@ -28,10 +30,10 @@ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base
/**
* Constructor.
*
- * @param phpbb_config $config The config
- * @param phpbb_user $user The user
+ * @param \phpbb\config\config $config The config
+ * @param \phpbb\user $user The user
*/
- public function __construct(phpbb_config $config, phpbb_user $user)
+ public function __construct(\phpbb\config\config $config, \phpbb\user $user)
{
$this->config = $config;
$this->user = $user;
diff --git a/phpBB/phpbb/cron/task/core/tidy_warnings.php b/phpBB/phpbb/cron/task/core/tidy_warnings.php
index 2a7798e56e..1cc0abbe88 100644
--- a/phpBB/phpbb/cron/task/core/tidy_warnings.php
+++ b/phpBB/phpbb/cron/task/core/tidy_warnings.php
@@ -7,6 +7,8 @@
*
*/
+namespace phpbb\cron\task\core;
+
/**
* @ignore
*/
@@ -22,7 +24,7 @@ if (!defined('IN_PHPBB'))
*
* @package phpBB3
*/
-class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base
+class tidy_warnings extends \phpbb\cron\task\base
{
protected $phpbb_root_path;
protected $php_ext;
@@ -33,9 +35,9 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base
*
* @param string $phpbb_root_path The root path
* @param string $php_ext The PHP extension
- * @param phpbb_config $config The config
+ * @param \phpbb\config\config $config The config
*/
- public function __construct($phpbb_root_path, $php_ext, phpbb_config $config)
+ public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
diff --git a/phpBB/phpbb/cron/task/parametrized.php b/phpBB/phpbb/cron/task/parametrized.php
index 5f0e46eafc..1d2f449c58 100644
--- a/phpBB/phpbb/cron/task/parametrized.php
+++ b/phpBB/phpbb/cron/task/parametrized.php
@@ -7,6 +7,8 @@
*
*/
+namespace phpbb\cron\task;
+
/**
* @ignore
*/
@@ -26,7 +28,7 @@ if (!defined('IN_PHPBB'))
*
* @package phpBB3
*/
-interface phpbb_cron_task_parametrized extends phpbb_cron_task
+interface parametrized extends \phpbb\cron\task\task
{
/**
* Returns parameters of this cron task as an array.
@@ -39,14 +41,14 @@ interface phpbb_cron_task_parametrized extends phpbb_cron_task
/**
* Parses parameters found in $request, which is an instance of
- * phpbb_request_interface.
+ * \phpbb\request\request_interface.
*
* $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.
+ * @param \phpbb\request\request_interface $request Request object.
*
* @return null
*/
- public function parse_parameters(phpbb_request_interface $request);
+ public function parse_parameters(\phpbb\request\request_interface $request);
}
diff --git a/phpBB/phpbb/cron/task/task.php b/phpBB/phpbb/cron/task/task.php
index 2d585df96d..84218c4fc9 100644
--- a/phpBB/phpbb/cron/task/task.php
+++ b/phpBB/phpbb/cron/task/task.php
@@ -7,6 +7,8 @@
*
*/
+namespace phpbb\cron\task;
+
/**
* @ignore
*/
@@ -19,7 +21,7 @@ if (!defined('IN_PHPBB'))
* Cron task interface
* @package phpBB3
*/
-interface phpbb_cron_task
+interface task
{
/**
* Returns the name of the task.
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;
}
/**