aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/cron/task
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/cron/task')
-rw-r--r--phpBB/phpbb/cron/task/base.php12
-rw-r--r--phpBB/phpbb/cron/task/core/prune_all_forums.php18
-rw-r--r--phpBB/phpbb/cron/task/core/prune_forum.php20
-rw-r--r--phpBB/phpbb/cron/task/core/prune_notifications.php12
-rw-r--r--phpBB/phpbb/cron/task/core/prune_shadow_topics.php200
-rw-r--r--phpBB/phpbb/cron/task/core/queue.php16
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_cache.php12
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_database.php14
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_plupload.php20
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_search.php73
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_sessions.php12
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_warnings.php14
-rw-r--r--phpBB/phpbb/cron/task/parametrized.php12
-rw-r--r--phpBB/phpbb/cron/task/task.php11
-rw-r--r--phpBB/phpbb/cron/task/text_reparser/reparser.php168
-rw-r--r--phpBB/phpbb/cron/task/wrapper.php14
16 files changed, 530 insertions, 98 deletions
diff --git a/phpBB/phpbb/cron/task/base.php b/phpBB/phpbb/cron/task/base.php
index 63f0407bcd..57c9912d31 100644
--- a/phpBB/phpbb/cron/task/base.php
+++ b/phpBB/phpbb/cron/task/base.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -17,8 +21,6 @@ namespace phpbb\cron\task;
*
* Cron tasks need not inherit from this base class. If desired,
* they may implement cron task interface directly.
-*
-* @package phpBB3
*/
abstract class base implements \phpbb\cron\task\task
{
diff --git a/phpBB/phpbb/cron/task/core/prune_all_forums.php b/phpBB/phpbb/cron/task/core/prune_all_forums.php
index 90b9a5914b..b47939ccbe 100644
--- a/phpBB/phpbb/cron/task/core/prune_all_forums.php
+++ b/phpBB/phpbb/cron/task/core/prune_all_forums.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -15,8 +19,6 @@ namespace phpbb\cron\task\core;
* It is intended to be invoked from system cron.
* This task will find all forums for which pruning is enabled, and will
* prune all forums as necessary.
-*
-* @package phpBB3
*/
class prune_all_forums extends \phpbb\cron\task\base
{
@@ -29,11 +31,11 @@ class prune_all_forums extends \phpbb\cron\task\base
* Constructor.
*
* @param string $phpbb_root_path The root path
- * @param string $php_ext The PHP extension
+ * @param string $php_ext The PHP file extension
* @param \phpbb\config\config $config The config
- * @param \phpbb\db\driver\driver $db The db connection
+ * @param \phpbb\db\driver\driver_interface $db The db connection
*/
- public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver $db)
+ public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $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 e0d8b067c5..abf91aee19 100644
--- a/phpBB/phpbb/cron/task/core/prune_forum.php
+++ b/phpBB/phpbb/cron/task/core/prune_forum.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -15,8 +19,6 @@ namespace phpbb\cron\task\core;
* It is intended to be used when cron is invoked via web.
* This task can decide whether it should be run using data obtained by viewforum
* code, without making additional database queries.
-*
-* @package phpBB3
*/
class prune_forum extends \phpbb\cron\task\base implements \phpbb\cron\task\parametrized
{
@@ -29,7 +31,7 @@ class prune_forum extends \phpbb\cron\task\base implements \phpbb\cron\task\para
* If $forum_data is given, it is assumed to contain necessary information
* about a single forum that is to be pruned.
*
- * If $forum_data is not given, forum id will be retrieved via request_var
+ * If $forum_data is not given, forum id will be retrieved via $request->variable()
* and a database query will be performed to load the necessary information
* about the forum.
*/
@@ -39,11 +41,11 @@ class prune_forum extends \phpbb\cron\task\base implements \phpbb\cron\task\para
* Constructor.
*
* @param string $phpbb_root_path The root path
- * @param string $php_ext The PHP extension
+ * @param string $php_ext PHP file extension
* @param \phpbb\config\config $config The config
- * @param \phpbb\db\driver\driver $db The db connection
+ * @param \phpbb\db\driver\driver_interface $db The db connection
*/
- public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver $db)
+ public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
diff --git a/phpBB/phpbb/cron/task/core/prune_notifications.php b/phpBB/phpbb/cron/task/core/prune_notifications.php
index 9f67c54e1c..ffa7e17970 100644
--- a/phpBB/phpbb/cron/task/core/prune_notifications.php
+++ b/phpBB/phpbb/cron/task/core/prune_notifications.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2013 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -11,8 +15,6 @@ namespace phpbb\cron\task\core;
/**
* Prune notifications cron task.
-*
-* @package phpBB3
*/
class prune_notifications extends \phpbb\cron\task\base
{
diff --git a/phpBB/phpbb/cron/task/core/prune_shadow_topics.php b/phpBB/phpbb/cron/task/core/prune_shadow_topics.php
new file mode 100644
index 0000000000..0ab59f9ed5
--- /dev/null
+++ b/phpBB/phpbb/cron/task/core/prune_shadow_topics.php
@@ -0,0 +1,200 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\cron\task\core;
+
+/**
+* Prune one forum of its shadow topics cron task.
+*
+* It is intended to be used when cron is invoked via web.
+* This task can decide whether it should be run using data obtained by viewforum
+* code, without making additional database queries.
+*/
+class prune_shadow_topics extends \phpbb\cron\task\base implements \phpbb\cron\task\parametrized
+{
+ protected $phpbb_root_path;
+ protected $php_ext;
+ protected $config;
+ protected $db;
+ protected $log;
+ protected $user;
+
+ /**
+ * If $forum_data is given, it is assumed to contain necessary information
+ * about a single forum that is to be pruned.
+ *
+ * If $forum_data is not given, forum id will be retrieved via $request->variable()
+ * and a database query will be performed to load the necessary information
+ * about the forum.
+ */
+ protected $forum_data;
+
+ /**
+ * Constructor.
+ *
+ * @param string $phpbb_root_path The root path
+ * @param string $php_ext PHP file extension
+ * @param \phpbb\config\config $config The config
+ * @param \phpbb\db\driver\driver_interface $db The db connection
+ * @param \phpbb\log\log $log The phpBB log system
+ * @param \phpbb\user $user The phpBB user object
+ */
+ public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\log\log $log, \phpbb\user $user)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+ $this->config = $config;
+ $this->db = $db;
+ $this->log = $log;
+ $this->user = $user;
+ }
+
+ /**
+ * Manually set forum data.
+ *
+ * @param array $forum_data Information about a forum to be pruned.
+ */
+ public function set_forum_data($forum_data)
+ {
+ $this->forum_data = $forum_data;
+ }
+
+ /**
+ * Runs this cron task.
+ *
+ * @return null
+ */
+ public function run()
+ {
+ if (!function_exists('auto_prune'))
+ {
+ include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext);
+ }
+
+ if ($this->forum_data['prune_shadow_days'])
+ {
+ $this->auto_prune_shadow_topics($this->forum_data['forum_id'], 'shadow', $this->forum_data['forum_flags'], $this->forum_data['prune_shadow_days'], $this->forum_data['prune_shadow_freq']);
+ }
+ }
+
+ /**
+ * 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()
+ {
+ return !$this->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.
+ *
+ * Forum pruning interval is specified in the forum data.
+ *
+ * @return bool
+ */
+ public function should_run()
+ {
+ return $this->forum_data['enable_shadow_prune'] && $this->forum_data['prune_shadow_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.
+ *
+ * @return array
+ */
+ public function get_parameters()
+ {
+ return array('f' => $this->forum_data['forum_id']);
+ }
+
+ /**
+ * Parses parameters found in $request, which is an instance of
+ * \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\request_interface $request Request object.
+ *
+ * @return null
+ */
+ public function parse_parameters(\phpbb\request\request_interface $request)
+ {
+ $this->forum_data = null;
+ if ($request->is_set('f'))
+ {
+ $forum_id = $request->variable('f', 0);
+
+ $sql = 'SELECT forum_id, prune_shadow_next, enable_shadow_prune, prune_shadow_days, forum_flags, prune_shadow_freq
+ FROM ' . FORUMS_TABLE . "
+ WHERE forum_id = $forum_id";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ if ($row)
+ {
+ $this->forum_data = $row;
+ }
+ }
+ }
+
+ /**
+ * Automatically prune shadow topics
+ * Based on fuunction auto_prune()
+ * @param int $forum_id Forum ID of forum that should be pruned
+ * @param string $prune_mode Prune mode
+ * @param int $prune_flags Prune flags
+ * @param int $prune_days Prune date in days
+ * @param int $prune_freq Prune frequency
+ * @return null
+ */
+ protected function auto_prune_shadow_topics($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_freq)
+ {
+ $sql = 'SELECT forum_name
+ FROM ' . FORUMS_TABLE . "
+ WHERE forum_id = $forum_id";
+ $result = $this->db->sql_query($sql, 3600);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ if ($row)
+ {
+ $prune_date = time() - ($prune_days * 86400);
+ $next_prune = time() + ($prune_freq * 86400);
+
+ prune($forum_id, $prune_mode, $prune_date, $prune_flags, true);
+
+ $sql = 'UPDATE ' . FORUMS_TABLE . "
+ SET prune_shadow_next = $next_prune
+ WHERE forum_id = $forum_id";
+ $this->db->sql_query($sql);
+
+ $user_id = (empty($this->user->data)) ? ANONYMOUS : $this->user->data['user_id'];
+ $user_ip = (empty($this->user->ip)) ? '' : $this->user->ip;
+
+ $this->log->add('admin', $user_id, $user_ip, 'LOG_PRUNE_SHADOW', false, array($row['forum_name']));
+ }
+
+ return;
+ }
+}
diff --git a/phpBB/phpbb/cron/task/core/queue.php b/phpBB/phpbb/cron/task/core/queue.php
index cd799b8024..a9345a44df 100644
--- a/phpBB/phpbb/cron/task/core/queue.php
+++ b/phpBB/phpbb/cron/task/core/queue.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -11,8 +15,6 @@ namespace phpbb\cron\task\core;
/**
* Queue cron task. Sends email and jabber messages queued by other scripts.
-*
-* @package phpBB3
*/
class queue extends \phpbb\cron\task\base
{
@@ -24,7 +26,7 @@ class queue extends \phpbb\cron\task\base
* Constructor.
*
* @param string $phpbb_root_path The root path
- * @param string $php_ext The PHP extension
+ * @param string $php_ext PHP file extension
* @param \phpbb\config\config $config The config
*/
public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config)
@@ -71,6 +73,6 @@ class queue extends \phpbb\cron\task\base
*/
public function should_run()
{
- return $this->config['last_queue_run'] < time() - $this->config['queue_interval_config'];
+ return $this->config['last_queue_run'] < time() - $this->config['queue_interval'];
}
}
diff --git a/phpBB/phpbb/cron/task/core/tidy_cache.php b/phpBB/phpbb/cron/task/core/tidy_cache.php
index a94a85db53..506a245f0f 100644
--- a/phpBB/phpbb/cron/task/core/tidy_cache.php
+++ b/phpBB/phpbb/cron/task/core/tidy_cache.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -11,8 +15,6 @@ namespace phpbb\cron\task\core;
/**
* Tidy cache cron task.
-*
-* @package phpBB3
*/
class tidy_cache extends \phpbb\cron\task\base
{
diff --git a/phpBB/phpbb/cron/task/core/tidy_database.php b/phpBB/phpbb/cron/task/core/tidy_database.php
index f712a5047c..949bba8012 100644
--- a/phpBB/phpbb/cron/task/core/tidy_database.php
+++ b/phpBB/phpbb/cron/task/core/tidy_database.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -11,8 +15,6 @@ namespace phpbb\cron\task\core;
/**
* Tidy database cron task.
-*
-* @package phpBB3
*/
class tidy_database extends \phpbb\cron\task\base
{
@@ -24,7 +26,7 @@ class tidy_database extends \phpbb\cron\task\base
* Constructor.
*
* @param string $phpbb_root_path The root path
- * @param string $php_ext The PHP extension
+ * @param string $php_ext The PHP file extension
* @param \phpbb\config\config $config The config
*/
public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config)
diff --git a/phpBB/phpbb/cron/task/core/tidy_plupload.php b/phpBB/phpbb/cron/task/core/tidy_plupload.php
index 5a98e0bd7b..d7364374af 100644
--- a/phpBB/phpbb/cron/task/core/tidy_plupload.php
+++ b/phpBB/phpbb/cron/task/core/tidy_plupload.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2013 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -11,8 +15,6 @@ namespace phpbb\cron\task\core;
/**
* Cron task for cleaning plupload's temporary upload directory.
-*
-* @package phpBB3
*/
class tidy_plupload extends \phpbb\cron\task\base
{
@@ -65,6 +67,8 @@ class tidy_plupload extends \phpbb\cron\task\base
*/
public function run()
{
+ global $user, $phpbb_log;
+
// Remove old temporary file (perhaps failed uploads?)
$last_valid_timestamp = time() - $this->max_file_age;
try
@@ -86,13 +90,11 @@ class tidy_plupload extends \phpbb\cron\task\base
}
catch (\UnexpectedValueException $e)
{
- add_log(
- 'critical',
- 'LOG_PLUPLOAD_TIDY_FAILED',
+ $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_PLUPLOAD_TIDY_FAILED', false, array(
$this->plupload_upload_path,
$e->getMessage(),
$e->getTraceAsString()
- );
+ ));
}
$this->config->set('plupload_last_gc', time(), true);
diff --git a/phpBB/phpbb/cron/task/core/tidy_search.php b/phpBB/phpbb/cron/task/core/tidy_search.php
index 42f7df308f..eb3970254f 100644
--- a/phpBB/phpbb/cron/task/core/tidy_search.php
+++ b/phpBB/phpbb/cron/task/core/tidy_search.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -13,29 +17,63 @@ namespace phpbb\cron\task\core;
* Tidy search cron task.
*
* Will only run when the currently selected search backend supports tidying.
-*
-* @package phpBB3
*/
class tidy_search extends \phpbb\cron\task\base
{
+ /**
+ * phpBB root path
+ * @var string
+ */
protected $phpbb_root_path;
+
+ /**
+ * PHP file extension
+ * @var string
+ */
protected $php_ext;
+
+ /**
+ * Auth object
+ * @var \phpbb\auth\auth
+ */
protected $auth;
+
+ /**
+ * Config object
+ * @var \phpbb\config\config
+ */
protected $config;
+
+ /**
+ * Database object
+ * @var \phpbb\db\driver\driver_interface
+ */
protected $db;
+
+ /**
+ * User object
+ * @var \phpbb\user
+ */
protected $user;
/**
+ * Event dispatcher object
+ * @var \phpbb\event\dispatcher_interface
+ */
+ protected $phpbb_dispatcher;
+
+ /**
* Constructor.
*
- * @param string $phpbb_root_path The root path
- * @param string $php_ext The PHP extension
- * @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
+ * @param string $phpbb_root_path The phpBB root path
+ * @param string $php_ext The PHP file extension
+ * @param \phpbb\auth\auth $auth The auth object
+ * @param \phpbb\config\config $config The config object
+ * @param \phpbb\db\driver\driver_interface $db The database object
+ * @param \phpbb\user $user The user object
+ * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher The event dispatcher object
*/
- public function __construct($phpbb_root_path, $php_ext, \phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\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_interface $db, \phpbb\user $user, \phpbb\event\dispatcher_interface $phpbb_dispatcher)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
@@ -43,6 +81,7 @@ class tidy_search extends \phpbb\cron\task\base
$this->config = $config;
$this->db = $db;
$this->user = $user;
+ $this->phpbb_dispatcher = $phpbb_dispatcher;
}
/**
@@ -52,12 +91,11 @@ class tidy_search extends \phpbb\cron\task\base
*/
public function run()
{
- // Select the search method
- $search_type = basename($this->config['search_type']);
+ $search_type = $this->config['search_type'];
// We do some additional checks in the module to ensure it can actually be utilised
$error = false;
- $search = new $search_type($error, $this->phpbb_root_path, $this->php_ext, $this->auth, $this->config, $this->db, $this->user);
+ $search = new $search_type($error, $this->phpbb_root_path, $this->php_ext, $this->auth, $this->config, $this->db, $this->user, $this->phpbb_dispatcher);
if (!$error)
{
@@ -76,10 +114,7 @@ class tidy_search extends \phpbb\cron\task\base
*/
public function is_runnable()
{
- // Select the search method
- $search_type = basename($this->config['search_type']);
-
- return class_exists($search_type);
+ return class_exists($this->config['search_type']);
}
/**
diff --git a/phpBB/phpbb/cron/task/core/tidy_sessions.php b/phpBB/phpbb/cron/task/core/tidy_sessions.php
index 68094af1f7..5e6dabdabf 100644
--- a/phpBB/phpbb/cron/task/core/tidy_sessions.php
+++ b/phpBB/phpbb/cron/task/core/tidy_sessions.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -11,8 +15,6 @@ namespace phpbb\cron\task\core;
/**
* Tidy sessions cron task.
-*
-* @package phpBB3
*/
class tidy_sessions extends \phpbb\cron\task\base
{
diff --git a/phpBB/phpbb/cron/task/core/tidy_warnings.php b/phpBB/phpbb/cron/task/core/tidy_warnings.php
index a0ff23fc57..7b67eae6ef 100644
--- a/phpBB/phpbb/cron/task/core/tidy_warnings.php
+++ b/phpBB/phpbb/cron/task/core/tidy_warnings.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -13,8 +17,6 @@ namespace phpbb\cron\task\core;
* Tidy warnings cron task.
*
* Will only run when warnings are configured to expire.
-*
-* @package phpBB3
*/
class tidy_warnings extends \phpbb\cron\task\base
{
@@ -26,7 +28,7 @@ class tidy_warnings extends \phpbb\cron\task\base
* Constructor.
*
* @param string $phpbb_root_path The root path
- * @param string $php_ext The PHP extension
+ * @param string $php_ext PHP file extension
* @param \phpbb\config\config $config The config
*/
public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config)
diff --git a/phpBB/phpbb/cron/task/parametrized.php b/phpBB/phpbb/cron/task/parametrized.php
index 1aeead0399..7e190b9b86 100644
--- a/phpBB/phpbb/cron/task/parametrized.php
+++ b/phpBB/phpbb/cron/task/parametrized.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -17,8 +21,6 @@ namespace phpbb\cron\task;
* parametrized cron tasks perform actions on a particular object (or objects).
* Parametrized cron tasks do not make sense and are not usable without
* specifying these objects.
-*
-* @package phpBB3
*/
interface parametrized extends \phpbb\cron\task\task
{
diff --git a/phpBB/phpbb/cron/task/task.php b/phpBB/phpbb/cron/task/task.php
index 3ce3de9598..6d5a383d2d 100644
--- a/phpBB/phpbb/cron/task/task.php
+++ b/phpBB/phpbb/cron/task/task.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -11,7 +15,6 @@ namespace phpbb\cron\task;
/**
* Cron task interface
-* @package phpBB3
*/
interface task
{
diff --git a/phpBB/phpbb/cron/task/text_reparser/reparser.php b/phpBB/phpbb/cron/task/text_reparser/reparser.php
new file mode 100644
index 0000000000..aa644de827
--- /dev/null
+++ b/phpBB/phpbb/cron/task/text_reparser/reparser.php
@@ -0,0 +1,168 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\cron\task\text_reparser;
+
+/**
+ * Reparse text cron task
+ */
+class reparser extends \phpbb\cron\task\base
+{
+ const MIN = 1;
+ const SIZE = 100;
+
+ /**
+ * @var \phpbb\config\config
+ */
+ protected $config;
+
+ /**
+ * @var \phpbb\config\db_text
+ */
+ protected $config_text;
+
+ /**
+ * @var \phpbb\lock\db
+ */
+ protected $reparse_lock;
+
+ /**
+ * @var \phpbb\textreparser\manager
+ */
+ protected $reparser_manager;
+
+ /**
+ * @var string
+ */
+ protected $reparser_name;
+
+ /**
+ * @var \phpbb\di\service_collection
+ */
+ protected $reparsers;
+
+ /**
+ * @var array
+ */
+ protected $resume_data;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\config\config $config
+ * @param \phpbb\config\db_text $config_text
+ * @param \phpbb\lock\db $reparse_lock
+ * @param \phpbb\textreparser\manager $reparser_manager
+ * @param \phpbb\di\service_collection $reparsers
+ */
+ public function __construct(\phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\lock\db $reparse_lock, \phpbb\textreparser\manager $reparser_manager, \phpbb\di\service_collection $reparsers)
+ {
+ $this->config = $config;
+ $this->config_text = $config_text;
+ $this->reparse_lock = $reparse_lock;
+ $this->reparser_manager = $reparser_manager;
+ $this->reparsers = $reparsers;
+ }
+
+ /**
+ * Sets the reparser for this cron task
+ *
+ * @param string $reparser
+ */
+ public function set_reparser($reparser)
+ {
+ $this->reparser_name = (!isset($this->reparsers[$reparser]) ? 'text_reparser.' : '') . $reparser;
+
+ if ($this->resume_data === null)
+ {
+ $this->reparser_manager->get_resume_data($this->reparser_name);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function is_runnable()
+ {
+ if ($this->resume_data === null)
+ {
+ $this->reparser_manager->get_resume_data($this->reparser_name);
+ }
+
+ if (empty($this->resume_data['range-max']) || $this->resume_data['range-max'] >= $this->resume_data['range-min'])
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function should_run()
+ {
+ if (!empty($this->config['reparse_lock']))
+ {
+ $last_run = explode(' ', $this->config['reparse_lock']);
+
+ if ($last_run[0] + 3600 >= time())
+ {
+ return false;
+ }
+ }
+
+ if ($this->config[$this->reparser_name . '_cron_interval'])
+ {
+ return $this->config[$this->reparser_name . '_last_cron'] < time() - $this->config[$this->reparser_name . '_cron_interval'];
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function run()
+ {
+ if ($this->reparse_lock->acquire())
+ {
+ if ($this->resume_data === null)
+ {
+ $this->resume_data = $this->reparser_manager->get_resume_data($this->reparser_name);
+ }
+
+ /**
+ * @var \phpbb\textreparser\reparser_interface $reparser
+ */
+ $reparser = $this->reparsers[$this->reparser_name];
+
+ $min = !empty($this->resume_data['range-min']) ? $this->resume_data['range-min'] : self::MIN;
+ $current = !empty($this->resume_data['range-max']) ? $this->resume_data['range-max'] : $reparser->get_max_id();
+ $size = !empty($this->resume_data['range-size']) ? $this->resume_data['range-size'] : self::SIZE;
+
+ if ($current >= $min)
+ {
+ $start = max($min, $current + 1 - $size);
+ $end = max($min, $current);
+
+ $reparser->reparse_range($start, $end);
+
+ $this->reparser_manager->update_resume_data($this->reparser_name, $min, $start - 1, $size);
+ }
+
+ $this->config->set($this->reparser_name . '_last_cron', time());
+ $this->reparse_lock->release();
+ }
+ }
+}
diff --git a/phpBB/phpbb/cron/task/wrapper.php b/phpBB/phpbb/cron/task/wrapper.php
index fc3f897206..8a4a8b1f0c 100644
--- a/phpBB/phpbb/cron/task/wrapper.php
+++ b/phpBB/phpbb/cron/task/wrapper.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @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
{
@@ -27,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 file extension
*/
public function __construct(\phpbb\cron\task\task $task, $phpbb_root_path, $php_ext)
{