1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 05:50:42 +02:00

Merge remote-tracking branch 'upstream/develop' into ticket/11015

* upstream/develop: (666 commits)
  [ticket/11077] Remove code from old global announcements system
  [ticket/11189] Replace DEBUG_EXTRA with DEBUG
  [ticket/11189] Always log critical errors when in cron or in image output
  [ticket/11187] Added a blank array to fix errors in functional tests
  [ticket/10780] Make L_COLON available in the installer.
  [ticket/11183] Remove $load_extensions and weird dl() calls
  [ticket/10970] Added extra documentation to parse_dynamic_path.
  [ticket/10939] Added documentation for phpbb_request::file
  [ticket/10865] Use code tags for install/database_update.php.
  [ticket/10865] Should have been a slash.
  [ticket/10780] Use L_COLON on LDAP page.
  [ticket/10780] Use L_COLON on search backend ACP pages.
  [ticket/10780] Use L_COLON for "download all attachments".
  [ticket/10780] Use colon from language in ucp_pm_compose.php where possible.
  [ticket/10780] Replace colons in phpBB/adm/style/acp_ext_details.html.
  [ticket/10780] Replace colon usage in adm template output with {L_COLON}
  [ticket/10780] Replace colon usage in template output with {L_COLON}
  [ticket/11181] Bump PHP requirement to 5.3.3 (from 5.3.2) [develop-olympus]
  [ticket/11181] Bump PHP requirement to 5.3.3 (from 5.3.2)
  [ticket/10172] Show prosilver birthday list even if there are no birthdays.
  ...

Conflicts:
	phpBB/common.php
	phpBB/download/file.php
	phpBB/includes/db/dbal.php
	phpBB/includes/db/firebird.php
	phpBB/includes/db/mssql.php
	phpBB/includes/db/mssql_odbc.php
	phpBB/includes/db/mssqlnative.php
	phpBB/includes/db/mysql.php
	phpBB/includes/db/mysqli.php
	phpBB/includes/db/oracle.php
	phpBB/includes/db/postgres.php
	phpBB/includes/db/sqlite.php
	phpBB/includes/extension/manager.php
	phpBB/install/database_update.php
This commit is contained in:
Igor Wiedler
2012-11-12 10:33:40 +01:00
449 changed files with 12779 additions and 3043 deletions

View File

@@ -28,6 +28,28 @@ if (!defined('IN_PHPBB'))
*/
abstract class phpbb_cron_task_base implements phpbb_cron_task
{
private $name;
/**
* Returns the name of the task.
*
* @return string Name of wrapped task.
*/
public function get_name()
{
return $this->name;
}
/**
* Sets the name of the task.
*
* @param string $name The task name
*/
public function set_name($name)
{
$this->name = $name;
}
/**
* Returns whether this cron task can run, given current board configuration.
*

View File

@@ -26,6 +26,27 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base
{
protected $phpbb_root_path;
protected $php_ext;
protected $config;
protected $db;
/**
* Constructor.
*
* @param string $phpbb_root_path The root path
* @param string $php_ext The PHP extension
* @param phpbb_config $config The config
* @param dbal $db The db connection
*/
public function __construct($phpbb_root_path, $php_ext, phpbb_config $config, phpbb_db_driver $db)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->config = $config;
$this->db = $db;
}
/**
* Runs this cron task.
*
@@ -33,19 +54,17 @@ 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);
include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext);
}
$sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq
FROM ' . FORUMS_TABLE . "
WHERE enable_prune = 1
WHERE enable_prune = 1
AND prune_next < " . time();
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
if ($row['prune_days'])
{
@@ -57,7 +76,7 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base
auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']);
}
}
$db->sql_freeresult($result);
$this->db->sql_freeresult($result);
}
/**
@@ -69,7 +88,6 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base
*/
public function is_runnable()
{
global $config;
return (bool) $config['use_system_cron'];
return (bool) $this->config['use_system_cron'];
}
}

View File

@@ -26,31 +26,45 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements phpbb_cron_task_parametrized
{
private $forum_data;
protected $phpbb_root_path;
protected $php_ext;
protected $config;
protected $db;
/**
* Constructor.
*
* 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
* 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 The PHP extension
* @param phpbb_config $config The config
* @param dbal $db The db connection
*/
public function __construct($phpbb_root_path, $php_ext, phpbb_config $config, phpbb_db_driver $db)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->config = $config;
$this->db = $db;
}
/**
* Manually set forum data.
*
* @param array $forum_data Information about a forum to be pruned.
*/
public function __construct($forum_data = null)
public function set_forum_data($forum_data)
{
global $db;
if ($forum_data)
{
$this->forum_data = $forum_data;
}
else
{
$this->forum_data = null;
}
$this->forum_data = $forum_data;
}
/**
@@ -60,10 +74,9 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p
*/
public function run()
{
global $phpbb_root_path, $phpEx;
if (!function_exists('auto_prune'))
{
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext);
}
if ($this->forum_data['prune_days'])
@@ -90,8 +103,7 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p
*/
public function is_runnable()
{
global $config;
return !$config['use_system_cron'] && $this->forum_data;
return !$this->config['use_system_cron'] && $this->forum_data;
}
/**
@@ -130,8 +142,6 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p
*/
public function parse_parameters(phpbb_request_interface $request)
{
global $db;
$this->forum_data = null;
if ($request->is_set('f'))
{
@@ -140,9 +150,9 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p
$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);
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
if ($row)
{

View File

@@ -22,6 +22,24 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_queue extends phpbb_cron_task_base
{
protected $phpbb_root_path;
protected $php_ext;
protected $config;
/**
* Constructor.
*
* @param string $phpbb_root_path The root path
* @param string $php_ext The PHP extension
* @param phpbb_config $config The config
*/
public function __construct($phpbb_root_path, $php_ext, phpbb_config $config)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->config = $config;
}
/**
* Runs this cron task.
*
@@ -29,10 +47,9 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base
*/
public function run()
{
global $phpbb_root_path, $phpEx;
if (!class_exists('queue'))
{
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
include($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);
}
$queue = new queue();
$queue->process();
@@ -47,8 +64,7 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base
*/
public function is_runnable()
{
global $phpbb_root_path, $phpEx;
return file_exists($phpbb_root_path . 'cache/queue.' . $phpEx);
return file_exists($this->phpbb_root_path . 'cache/queue.' . $this->php_ext);
}
/**
@@ -61,7 +77,6 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base
*/
public function should_run()
{
global $config;
return $config['last_queue_run'] < time() - $config['queue_interval_config'];
return $this->config['last_queue_run'] < time() - $this->config['queue_interval_config'];
}
}

View File

@@ -22,6 +22,21 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base
{
protected $config;
protected $cache;
/**
* Constructor.
*
* @param phpbb_config $config The config
* @param phpbb_cache_driver_interface $cache The cache driver
*/
public function __construct(phpbb_config $config, phpbb_cache_driver_interface $cache)
{
$this->config = $config;
$this->cache = $cache;
}
/**
* Runs this cron task.
*
@@ -29,8 +44,7 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base
*/
public function run()
{
global $cache;
$cache->tidy();
$this->cache->tidy();
}
/**
@@ -43,8 +57,7 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base
*/
public function is_runnable()
{
global $cache;
return method_exists($cache, 'tidy');
return true;
}
/**
@@ -58,7 +71,6 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base
*/
public function should_run()
{
global $config;
return $config['cache_last_gc'] < time() - $config['cache_gc'];
return $this->config['cache_last_gc'] < time() - $this->config['cache_gc'];
}
}

View File

@@ -22,6 +22,24 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base
{
protected $phpbb_root_path;
protected $php_ext;
protected $config;
/**
* Constructor.
*
* @param string $phpbb_root_path The root path
* @param string $php_ext The PHP extension
* @param phpbb_config $config The config
*/
public function __construct($phpbb_root_path, $php_ext, phpbb_config $config)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->config = $config;
}
/**
* Runs this cron task.
*
@@ -29,10 +47,9 @@ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base
*/
public function run()
{
global $phpbb_root_path, $phpEx;
if (!function_exists('tidy_database'))
{
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext);
}
tidy_database();
}
@@ -48,7 +65,6 @@ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base
*/
public function should_run()
{
global $config;
return $config['database_last_gc'] < time() - $config['database_gc'];
return $this->config['database_last_gc'] < time() - $this->config['database_gc'];
}
}

View File

@@ -24,6 +24,33 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base
{
protected $phpbb_root_path;
protected $php_ext;
protected $auth;
protected $config;
protected $db;
protected $user;
/**
* Constructor.
*
* @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 dbal $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)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->auth = $auth;
$this->config = $config;
$this->db = $db;
$this->user = $user;
}
/**
* Runs this cron task.
*
@@ -31,19 +58,17 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base
*/
public function run()
{
global $phpbb_root_path, $phpEx, $config, $error;
// Select the search method
$search_type = basename($config['search_type']);
$search_type = basename($this->config['search_type']);
if (!class_exists($search_type))
{
include("{$phpbb_root_path}includes/search/$search_type.$phpEx");
include($this->phpbb_root_path . "includes/search/$search_type." . $this->php_ext);
}
// We do some additional checks in the module to ensure it can actually be utilised
$error = false;
$search = new $search_type($error);
$search = new $search_type($error, $this->phpbb_root_path, $this->php_ext, $this->auth, $this->config, $this->db, $this->user);
if (!$error)
{
@@ -62,12 +87,10 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base
*/
public function is_runnable()
{
global $phpbb_root_path, $phpEx, $config;
// Select the search method
$search_type = basename($config['search_type']);
$search_type = basename($this->config['search_type']);
return file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx);
return file_exists($this->phpbb_root_path . 'includes/search/' . $search_type . '.' . $this->php_ext);
}
/**
@@ -81,7 +104,6 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base
*/
public function should_run()
{
global $config;
return $config['search_last_gc'] < time() - $config['search_gc'];
return $this->config['search_last_gc'] < time() - $this->config['search_gc'];
}
}

View File

@@ -22,6 +22,21 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base
{
protected $config;
protected $user;
/**
* Constructor.
*
* @param phpbb_config $config The config
* @param phpbb_user $user The user
*/
public function __construct(phpbb_config $config, phpbb_user $user)
{
$this->config = $config;
$this->user = $user;
}
/**
* Runs this cron task.
*
@@ -29,8 +44,7 @@ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base
*/
public function run()
{
global $user;
$user->session_gc();
$this->user->session_gc();
}
/**
@@ -44,7 +58,6 @@ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base
*/
public function should_run()
{
global $config;
return $config['session_last_gc'] < time() - $config['session_gc'];
return $this->config['session_last_gc'] < time() - $this->config['session_gc'];
}
}

View File

@@ -24,6 +24,24 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base
{
protected $phpbb_root_path;
protected $php_ext;
protected $config;
/**
* Constructor.
*
* @param string $phpbb_root_path The root path
* @param string $php_ext The PHP extension
* @param phpbb_config $config The config
*/
public function __construct($phpbb_root_path, $php_ext, phpbb_config $config)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->config = $config;
}
/**
* Runs this cron task.
*
@@ -31,10 +49,9 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base
*/
public function run()
{
global $phpbb_root_path, $phpEx;
if (!function_exists('tidy_warnings'))
{
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext);
}
tidy_warnings();
}
@@ -48,8 +65,7 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base
*/
public function is_runnable()
{
global $config;
return (bool) $config['warnings_expire_days'];
return (bool) $this->config['warnings_expire_days'];
}
/**
@@ -63,7 +79,6 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base
*/
public function should_run()
{
global $config;
return $config['warnings_last_gc'] < time() - $config['warnings_gc'];
return $this->config['warnings_last_gc'] < time() - $this->config['warnings_gc'];
}
}

View File

@@ -15,6 +15,8 @@ if (!defined('IN_PHPBB'))
exit;
}
use Symfony\Component\DependencyInjection\TaggedContainerInterface;
/**
* Provides cron manager with tasks
*
@@ -22,27 +24,36 @@ if (!defined('IN_PHPBB'))
*
* @package phpBB3
*/
class phpbb_cron_task_provider extends phpbb_extension_provider
class phpbb_cron_task_provider implements IteratorAggregate
{
/**
* Finds cron task names using the extension manager.
*
* All PHP files in includes/cron/task/core/ are considered tasks. Tasks
* in extensions have to be located in a directory called cron or a subdir
* of a directory called cron. The class and filename must end in a _task
* suffix. Additionally all PHP files in includes/cron/task/core/ are
* tasks.
*
* @return array List of task names
*/
protected function find()
{
$finder = $this->extension_manager->get_finder();
private $container;
return $finder
->extension_suffix('_task')
->extension_directory('/cron')
->core_path('includes/cron/task/core/')
->get_classes();
public function __construct(TaggedContainerInterface $container)
{
$this->container = $container;
}
/**
* Retrieve an iterator over all items
*
* @return ArrayIterator An iterator for the array of cron tasks
*/
public function getIterator()
{
$definitions = $this->container->findTaggedServiceIds('cron.task');
$tasks = array();
foreach ($definitions as $name => $definition)
{
$task = $this->container->get($name);
if ($task instanceof phpbb_cron_task_base)
{
$task->set_name($name);
}
$tasks[] = $task;
}
return new ArrayIterator($tasks);
}
}

View File

@@ -21,6 +21,13 @@ if (!defined('IN_PHPBB'))
*/
interface phpbb_cron_task
{
/**
* Returns the name of the task.
*
* @return string Name of wrapped task.
*/
public function get_name();
/**
* Runs this cron task.
*

View File

@@ -23,6 +23,10 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_wrapper
{
protected $task;
protected $phpbb_root_path;
protected $php_ext;
/**
* Constructor.
*
@@ -30,9 +34,11 @@ class phpbb_cron_task_wrapper
*
* @param phpbb_cron_task $task The cron task to wrap.
*/
public function __construct(phpbb_cron_task $task)
public function __construct(phpbb_cron_task $task, $phpbb_root_path, $php_ext)
{
$this->task = $task;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
}
/**
@@ -61,16 +67,6 @@ class phpbb_cron_task_wrapper
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.
*
* @return string Class name of wrapped task.
*/
public function get_name()
{
return get_class($this->task);
}
/**
* Returns a url through which this task may be invoked via web.
*
@@ -82,8 +78,6 @@ class phpbb_cron_task_wrapper
*/
public function get_url()
{
global $phpbb_root_path, $phpEx;
$name = $this->get_name();
if ($this->is_parametrized())
{
@@ -98,7 +92,7 @@ class phpbb_cron_task_wrapper
{
$extra = '';
}
$url = append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=' . $name . $extra);
$url = append_sid($this->phpbb_root_path . 'cron.' . $this->php_ext, 'cron_type=' . $name . $extra);
return $url;
}