mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into ticket/10631
Conflicts: phpBB/common.php phpBB/download/file.php
This commit is contained in:
commit
79da1ea592
47 changed files with 1172 additions and 288 deletions
|
@ -8,6 +8,10 @@
|
|||
* Minimum Requirement: PHP 5.3.2
|
||||
*/
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
|
||||
/**
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
|
@ -15,8 +19,6 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
|
||||
require($phpbb_root_path . 'includes/startup.' . $phpEx);
|
||||
|
||||
if (file_exists($phpbb_root_path . 'config.' . $phpEx))
|
||||
|
@ -74,61 +76,61 @@ if (!empty($load_extensions) && function_exists('dl'))
|
|||
|
||||
// Include files
|
||||
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx);
|
||||
|
||||
require($phpbb_root_path . 'includes/functions.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
|
||||
|
||||
require($phpbb_root_path . 'includes/constants.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/db/' . ltrim($dbms, 'dbal_') . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
|
||||
|
||||
// Set PHP error handler to ours
|
||||
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
|
||||
|
||||
$phpbb_container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/config'));
|
||||
$loader->load('services.yml');
|
||||
|
||||
$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx);
|
||||
$processor->process($phpbb_container);
|
||||
|
||||
// Setup class loader first
|
||||
$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx");
|
||||
$phpbb_class_loader_ext->register();
|
||||
$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx");
|
||||
$phpbb_class_loader->register();
|
||||
$phpbb_class_loader = $phpbb_container->get('class_loader');
|
||||
$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
|
||||
|
||||
$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$processor = $phpbb_container->get($id);
|
||||
$processor->process($phpbb_container);
|
||||
}
|
||||
|
||||
// set up caching
|
||||
$cache_factory = new phpbb_cache_factory($acm_type);
|
||||
$cache = $cache_factory->get_service();
|
||||
$phpbb_class_loader_ext->set_cache($cache->get_driver());
|
||||
$phpbb_class_loader->set_cache($cache->get_driver());
|
||||
$cache = $phpbb_container->get('cache');
|
||||
|
||||
// Instantiate some basic classes
|
||||
$phpbb_dispatcher = new phpbb_event_dispatcher();
|
||||
$request = new phpbb_request();
|
||||
$user = new phpbb_user();
|
||||
$auth = new phpbb_auth();
|
||||
$db = new $sql_db();
|
||||
$phpbb_dispatcher = $phpbb_container->get('dispatcher');
|
||||
$request = $phpbb_container->get('request');
|
||||
$user = $phpbb_container->get('user');
|
||||
$auth = $phpbb_container->get('auth');
|
||||
$db = $phpbb_container->get('dbal.conn');
|
||||
|
||||
// make sure request_var uses this request instance
|
||||
request_var('', 0, false, false, $request); // "dependency injection" for a function
|
||||
|
||||
// Connect to DB
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
|
||||
|
||||
// We do not need this any longer, unset for safety purposes
|
||||
unset($dbpasswd);
|
||||
|
||||
// Grab global variables, re-cache if necessary
|
||||
$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE);
|
||||
$config = $phpbb_container->get('config');
|
||||
set_config(null, null, null, $config);
|
||||
set_config_count(null, null, null, $config);
|
||||
|
||||
// load extensions
|
||||
$phpbb_extension_manager = new phpbb_extension_manager($db, $config, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver());
|
||||
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
|
||||
$phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader');
|
||||
|
||||
// Initialize style
|
||||
$phpbb_style_resource_locator = new phpbb_style_resource_locator();
|
||||
$phpbb_style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider());
|
||||
$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator);
|
||||
$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template);
|
||||
|
||||
$phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager);
|
||||
$phpbb_subscriber_loader->load();
|
||||
$template = $phpbb_container->get('template');
|
||||
$phpbb_style = $phpbb_container->get('style');
|
||||
|
||||
// Add own hook handler
|
||||
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
|
||||
|
@ -141,7 +143,7 @@ foreach ($cache->obtain_hooks() as $hook)
|
|||
|
||||
if (!$config['use_system_cron'])
|
||||
{
|
||||
$cron = new phpbb_cron_manager(new phpbb_cron_task_provider($phpbb_extension_manager), $cache->get_driver());
|
||||
$cron = $phpbb_container->get('cron.manager');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
{
|
||||
"minimum-stability": "beta",
|
||||
"require": {
|
||||
"symfony/event-dispatcher": "2.1.*"
|
||||
"symfony/config": "2.1.*",
|
||||
"symfony/dependency-injection": "2.1.*",
|
||||
"symfony/event-dispatcher": "2.1.*",
|
||||
"symfony/yaml": "2.1.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"fabpot/goutte": "1.0.x-dev"
|
||||
|
|
42
phpBB/composer.lock
generated
42
phpBB/composer.lock
generated
|
@ -1,9 +1,21 @@
|
|||
{
|
||||
"hash": "b2daff7465c71d924e915e72454ac266",
|
||||
"hash": "1632798bc1d5298a4f5bd3087c972a9f",
|
||||
"packages": [
|
||||
{
|
||||
"package": "symfony/config",
|
||||
"version": "v2.1.0-RC1"
|
||||
},
|
||||
{
|
||||
"package": "symfony/dependency-injection",
|
||||
"version": "v2.1.0-RC1"
|
||||
},
|
||||
{
|
||||
"package": "symfony/event-dispatcher",
|
||||
"version": "v2.1.0-BETA3"
|
||||
"version": "v2.1.0-RC1"
|
||||
},
|
||||
{
|
||||
"package": "symfony/yaml",
|
||||
"version": "v2.1.0-RC1"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
|
@ -16,32 +28,40 @@
|
|||
{
|
||||
"package": "fabpot/goutte",
|
||||
"version": "dev-master",
|
||||
"source-reference": "c2ea8d9a6682d14482e57ede2371001b8a5238d2",
|
||||
"commit-date": "1340264258"
|
||||
"source-reference": "6d26279344736f6983a969e46afef082ebf30a67",
|
||||
"commit-date": "1345141401"
|
||||
},
|
||||
{
|
||||
"package": "guzzle/guzzle",
|
||||
"version": "v2.6.6"
|
||||
"package": "guzzle/common",
|
||||
"version": "v2.8.4"
|
||||
},
|
||||
{
|
||||
"package": "guzzle/http",
|
||||
"version": "v2.8.4"
|
||||
},
|
||||
{
|
||||
"package": "guzzle/parser",
|
||||
"version": "v2.8.4"
|
||||
},
|
||||
{
|
||||
"package": "symfony/browser-kit",
|
||||
"version": "v2.1.0-BETA3"
|
||||
"version": "v2.1.0-RC1"
|
||||
},
|
||||
{
|
||||
"package": "symfony/css-selector",
|
||||
"version": "v2.1.0-BETA3"
|
||||
"version": "v2.1.0-RC1"
|
||||
},
|
||||
{
|
||||
"package": "symfony/dom-crawler",
|
||||
"version": "v2.1.0-BETA3"
|
||||
"version": "v2.1.0-RC1"
|
||||
},
|
||||
{
|
||||
"package": "symfony/finder",
|
||||
"version": "v2.1.0-BETA3"
|
||||
"version": "v2.1.0-RC1"
|
||||
},
|
||||
{
|
||||
"package": "symfony/process",
|
||||
"version": "v2.1.0-BETA3"
|
||||
"version": "v2.1.0-RC1"
|
||||
}
|
||||
],
|
||||
"aliases": [
|
||||
|
|
4
phpBB/config/.htaccess
Normal file
4
phpBB/config/.htaccess
Normal file
|
@ -0,0 +1,4 @@
|
|||
<Files *>
|
||||
Order Allow,Deny
|
||||
Deny from All
|
||||
</Files>
|
75
phpBB/config/cron_tasks.yml
Normal file
75
phpBB/config/cron_tasks.yml
Normal file
|
@ -0,0 +1,75 @@
|
|||
services:
|
||||
cron.task.core.prune_all_forums:
|
||||
class: phpbb_cron_task_core_prune_all_forums
|
||||
arguments:
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @config
|
||||
- @dbal.conn
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
cron.task.core.prune_forum:
|
||||
class: phpbb_cron_task_core_prune_forum
|
||||
arguments:
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @config
|
||||
- @dbal.conn
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
cron.task.core.queue:
|
||||
class: phpbb_cron_task_core_queue
|
||||
arguments:
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @config
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
cron.task.core.tidy_cache:
|
||||
class: phpbb_cron_task_core_tidy_cache
|
||||
arguments:
|
||||
- @config
|
||||
- @cache.driver
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
cron.task.core.tidy_database:
|
||||
class: phpbb_cron_task_core_tidy_database
|
||||
arguments:
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @config
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
cron.task.core.tidy_search:
|
||||
class: phpbb_cron_task_core_tidy_search
|
||||
arguments:
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @auth
|
||||
- @config
|
||||
- @dbal.conn
|
||||
- @user
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
cron.task.core.tidy_sessions:
|
||||
class: phpbb_cron_task_core_tidy_sessions
|
||||
arguments:
|
||||
- @config
|
||||
- @user
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
cron.task.core.tidy_warnings:
|
||||
class: phpbb_cron_task_core_tidy_warnings
|
||||
arguments:
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @config
|
||||
tags:
|
||||
- { name: cron.task }
|
136
phpBB/config/services.yml
Normal file
136
phpBB/config/services.yml
Normal file
|
@ -0,0 +1,136 @@
|
|||
imports:
|
||||
- { resource: tables.yml }
|
||||
- { resource: cron_tasks.yml }
|
||||
|
||||
services:
|
||||
auth:
|
||||
class: phpbb_auth
|
||||
|
||||
cache:
|
||||
class: phpbb_cache_service
|
||||
arguments:
|
||||
- @cache.driver
|
||||
|
||||
cache.driver:
|
||||
class: %cache.driver.class%
|
||||
|
||||
cache.driver.install:
|
||||
class: phpbb_cache_driver_file
|
||||
|
||||
class_loader:
|
||||
class: phpbb_class_loader
|
||||
arguments:
|
||||
- phpbb_
|
||||
- %core.root_path%includes/
|
||||
- .%core.php_ext%
|
||||
calls:
|
||||
- [register, []]
|
||||
- [set_cache, [@cache.driver]]
|
||||
|
||||
class_loader.ext:
|
||||
class: phpbb_class_loader
|
||||
arguments:
|
||||
- phpbb_ext_
|
||||
- %core.root_path%ext/
|
||||
- .%core.php_ext%
|
||||
calls:
|
||||
- [register, []]
|
||||
- [set_cache, [@cache.driver]]
|
||||
|
||||
config:
|
||||
class: phpbb_config_db
|
||||
arguments:
|
||||
- @dbal.conn
|
||||
- @cache.driver
|
||||
- %tables.config%
|
||||
|
||||
cron.task_provider:
|
||||
class: phpbb_cron_task_provider
|
||||
arguments:
|
||||
- @container
|
||||
|
||||
cron.manager:
|
||||
class: phpbb_cron_manager
|
||||
arguments:
|
||||
- @cron.task_provider
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
|
||||
cron.lock_db:
|
||||
class: phpbb_lock_db
|
||||
arguments:
|
||||
- cron_lock
|
||||
- @config
|
||||
- @dbal.conn
|
||||
|
||||
dispatcher:
|
||||
class: phpbb_event_dispatcher
|
||||
|
||||
dbal.conn:
|
||||
class: %dbal.driver.class%
|
||||
calls:
|
||||
- [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]]
|
||||
|
||||
event.subscriber_loader:
|
||||
class: phpbb_event_extension_subscriber_loader
|
||||
arguments:
|
||||
- @dispatcher
|
||||
- @ext.manager
|
||||
calls:
|
||||
- [load, []]
|
||||
|
||||
ext.manager:
|
||||
class: phpbb_extension_manager
|
||||
arguments:
|
||||
- @dbal.conn
|
||||
- @config
|
||||
- %tables.ext%
|
||||
- %core.root_path%
|
||||
- .%core.php_ext%
|
||||
- @cache.driver
|
||||
|
||||
processor.config:
|
||||
class: phpbb_di_processor_ext
|
||||
arguments:
|
||||
- @ext.manager
|
||||
tags:
|
||||
- { name: container.processor }
|
||||
|
||||
request:
|
||||
class: phpbb_request
|
||||
|
||||
style:
|
||||
class: phpbb_style
|
||||
arguments:
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @config
|
||||
- @user
|
||||
- @style.resource_locator
|
||||
- @style.path_provider_ext
|
||||
- @template
|
||||
|
||||
style.resource_locator:
|
||||
class: phpbb_style_resource_locator
|
||||
|
||||
style.path_provider_ext:
|
||||
class: phpbb_style_extension_path_provider
|
||||
arguments:
|
||||
- @ext.manager
|
||||
- @style.path_provider
|
||||
|
||||
style.path_provider:
|
||||
class: phpbb_style_path_provider
|
||||
|
||||
template:
|
||||
class: phpbb_template
|
||||
arguments:
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @config
|
||||
- @user
|
||||
- @style.resource_locator
|
||||
- @style.path_provider_ext
|
||||
|
||||
user:
|
||||
class: phpbb_user
|
3
phpBB/config/tables.yml
Normal file
3
phpBB/config/tables.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
parameters:
|
||||
tables.config: %core.table_prefix%config
|
||||
tables.ext: %core.table_prefix%ext
|
|
@ -61,7 +61,7 @@ function do_cron($cron_lock, $run_tasks)
|
|||
|
||||
if ($config['use_system_cron'])
|
||||
{
|
||||
$cron = new phpbb_cron_manager(new phpbb_cron_task_provider($phpbb_extension_manager), $cache->get_driver());
|
||||
$cron = $phpbb_container->get('cron.manager');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -71,7 +71,7 @@ else
|
|||
output_image();
|
||||
}
|
||||
|
||||
$cron_lock = new phpbb_lock_db('cron_lock', $config, $db);
|
||||
$cron_lock = $phpbb_container->get('cron.lock_db');
|
||||
if ($cron_lock->acquire())
|
||||
{
|
||||
if ($config['use_system_cron'])
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
|
@ -14,7 +18,6 @@ define('IN_PHPBB', true);
|
|||
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
|
||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||
|
||||
|
||||
// Thank you sun.
|
||||
if (isset($_SERVER['CONTENT_TYPE']))
|
||||
{
|
||||
|
@ -39,26 +42,38 @@ if (isset($_GET['avatar']))
|
|||
}
|
||||
|
||||
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx);
|
||||
|
||||
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/constants.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
|
||||
|
||||
$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx");
|
||||
$phpbb_class_loader_ext->register();
|
||||
$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx");
|
||||
$phpbb_class_loader->register();
|
||||
$phpbb_container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config'));
|
||||
$loader->load('services.yml');
|
||||
|
||||
$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx);
|
||||
$processor->process($phpbb_container);
|
||||
|
||||
$phpbb_class_loader = $phpbb_container->get('class_loader');
|
||||
$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
|
||||
|
||||
$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$processor = $phpbb_container->get($id);
|
||||
$processor->process($phpbb_container);
|
||||
}
|
||||
|
||||
// set up caching
|
||||
$cache_factory = new phpbb_cache_factory($acm_type);
|
||||
$cache = $cache_factory->get_service();
|
||||
$phpbb_class_loader_ext->set_cache($cache->get_driver());
|
||||
$phpbb_class_loader->set_cache($cache->get_driver());
|
||||
$cache = $phpbb_container->get('cache');
|
||||
|
||||
$phpbb_dispatcher = new phpbb_event_dispatcher();
|
||||
$request = new phpbb_request();
|
||||
$db = new $sql_db();
|
||||
$phpbb_dispatcher = $phpbb_container->get('dispatcher');
|
||||
$request = $phpbb_container->get('request');
|
||||
$db = $phpbb_container->get('dbal.conn');
|
||||
|
||||
// Connect to DB
|
||||
if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false))
|
||||
|
@ -69,18 +84,16 @@ if (isset($_GET['avatar']))
|
|||
|
||||
request_var('', 0, false, false, $request);
|
||||
|
||||
// worst-case default
|
||||
$browser = strtolower($request->header('User-Agent', 'msie 6.0'));
|
||||
|
||||
$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE);
|
||||
$config = $phpbb_container->get('config');
|
||||
set_config(null, null, null, $config);
|
||||
set_config_count(null, null, null, $config);
|
||||
|
||||
// load extensions
|
||||
$phpbb_extension_manager = new phpbb_extension_manager($db, $config, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver());
|
||||
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
|
||||
$phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader');
|
||||
|
||||
$phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager);
|
||||
$phpbb_subscriber_loader->load();
|
||||
// worst-case default
|
||||
$browser = strtolower($request->header('User-Agent', 'msie 6.0'));
|
||||
|
||||
$filename = request_var('avatar', '');
|
||||
$avatar_group = false;
|
||||
|
|
2
phpBB/includes/cache/driver/memory.php
vendored
2
phpBB/includes/cache/driver/memory.php
vendored
|
@ -19,7 +19,7 @@ if (!defined('IN_PHPBB'))
|
|||
* ACM Abstract Memory Class
|
||||
* @package acm
|
||||
*/
|
||||
class phpbb_cache_driver_memory extends phpbb_cache_driver_base
|
||||
abstract class phpbb_cache_driver_memory extends phpbb_cache_driver_base
|
||||
{
|
||||
var $key_prefix;
|
||||
|
||||
|
|
0
phpBB/includes/cache/driver/redis.php
vendored
Executable file → Normal file
0
phpBB/includes/cache/driver/redis.php
vendored
Executable file → Normal file
42
phpBB/includes/cache/factory.php
vendored
42
phpBB/includes/cache/factory.php
vendored
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package acm
|
||||
* @copyright (c) 2010 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @package acm
|
||||
*/
|
||||
class phpbb_cache_factory
|
||||
{
|
||||
private $acm_type;
|
||||
|
||||
public function __construct($acm_type)
|
||||
{
|
||||
$this->acm_type = $acm_type;
|
||||
}
|
||||
|
||||
public function get_driver()
|
||||
{
|
||||
$class_name = 'phpbb_cache_driver_' . $this->acm_type;
|
||||
return new $class_name();
|
||||
}
|
||||
|
||||
public function get_service()
|
||||
{
|
||||
$driver = $this->get_driver();
|
||||
$service = new phpbb_cache_service($driver);
|
||||
return $service;
|
||||
}
|
||||
}
|
|
@ -32,31 +32,35 @@ class phpbb_cron_manager
|
|||
*/
|
||||
protected $tasks = array();
|
||||
|
||||
protected $phpbb_root_path;
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Constructor. Loads all available tasks.
|
||||
*
|
||||
* @param array|Traversable $task_names Provides an iterable set of task names
|
||||
* @param array|Traversable $tasks Provides an iterable set of task names
|
||||
*/
|
||||
public function __construct($task_names)
|
||||
public function __construct($tasks, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->load_tasks($task_names);
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
|
||||
$this->load_tasks($tasks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads tasks given by name, wraps them
|
||||
* and puts them into $this->tasks.
|
||||
*
|
||||
* @param array|Traversable $task_names Array of strings
|
||||
* @param array|Traversable $tasks Array of instances of phpbb_cron_task
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function load_tasks($task_names)
|
||||
public function load_tasks($tasks)
|
||||
{
|
||||
foreach ($task_names as $task_name)
|
||||
foreach ($tasks as $task)
|
||||
{
|
||||
$task = new $task_name();
|
||||
$wrapper = new phpbb_cron_task_wrapper($task);
|
||||
$this->tasks[] = $wrapper;
|
||||
$this->tasks[] = $this->wrap_task($task);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,25 +126,13 @@ class phpbb_cron_manager
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of parametrized cron task $name with args $args.
|
||||
* The constructed task is wrapped with cron task wrapper before being returned.
|
||||
* Wraps a task inside an instance of phpbb_cron_task_wrapper.
|
||||
*
|
||||
* @param string $name The task name, which is the same as cron task class name.
|
||||
* @param array $args Will be passed to the task class's constructor.
|
||||
*
|
||||
* @return phpbb_cron_task_wrapper|null
|
||||
* @param phpbb_cron_task $task The task.
|
||||
* @return phpbb_cron_task_wrapper The wrapped task.
|
||||
*/
|
||||
public function instantiate_task($name, array $args)
|
||||
public function wrap_task(phpbb_cron_task $task)
|
||||
{
|
||||
$task = $this->find_task($name);
|
||||
if ($task)
|
||||
{
|
||||
// task here is actually an instance of cron task wrapper
|
||||
$class = $task->get_name();
|
||||
$task = new $class($args);
|
||||
// need to wrap the new task too
|
||||
$task = new phpbb_cron_task_wrapper($task);
|
||||
}
|
||||
return $task;
|
||||
return new phpbb_cron_task_wrapper($task, $this->phpbb_root_path, $this->php_ext);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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, dbal $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
|
||||
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'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,32 +26,46 @@ 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, dbal $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)
|
||||
{
|
||||
global $db;
|
||||
if ($forum_data)
|
||||
public function set_forum_data($forum_data)
|
||||
{
|
||||
$this->forum_data = $forum_data;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->forum_data = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs this cron task.
|
||||
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,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'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, dbal $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, $auth, $db, $user;
|
||||
|
||||
// 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, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
|
||||
$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'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
76
phpBB/includes/di/processor/config.php
Normal file
76
phpBB/includes/di/processor/config.php
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* Configure the container for phpBB's services though
|
||||
* user-defined parameters defined in the config.php file.
|
||||
*/
|
||||
class phpbb_di_processor_config implements phpbb_di_processor_interface
|
||||
{
|
||||
private $config_file;
|
||||
private $phpbb_root_path;
|
||||
private $php_ext;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $config_file The config file
|
||||
* @param string $phpbb_root_path The root path
|
||||
* @param string $php_ext The PHP extension
|
||||
*/
|
||||
public function __construct($config_file, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->config_file = $config_file;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
require $this->config_file;
|
||||
|
||||
$container->setParameter('core.root_path', $this->phpbb_root_path);
|
||||
$container->setParameter('core.php_ext', $this->php_ext);
|
||||
|
||||
$container->setParameter('core.table_prefix', $table_prefix);
|
||||
$container->setParameter('cache.driver.class', $this->fix_acm_type($acm_type));
|
||||
$container->setParameter('dbal.driver.class', 'dbal_'.$dbms);
|
||||
$container->setParameter('dbal.dbhost', $dbhost);
|
||||
$container->setParameter('dbal.dbuser', $dbuser);
|
||||
$container->setParameter('dbal.dbpasswd', $dbpasswd);
|
||||
$container->setParameter('dbal.dbname', $dbname);
|
||||
$container->setParameter('dbal.dbport', $dbport);
|
||||
$container->setParameter('dbal.new_link', defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK);
|
||||
|
||||
$container->set('container', $container);
|
||||
}
|
||||
|
||||
protected function fix_acm_type($acm_type)
|
||||
{
|
||||
if (preg_match('#^[a-z]+$#', $acm_type))
|
||||
{
|
||||
return 'phpbb_cache_driver_'.$acm_type;
|
||||
}
|
||||
|
||||
return $acm_type;
|
||||
}
|
||||
}
|
54
phpBB/includes/di/processor/ext.php
Normal file
54
phpBB/includes/di/processor/ext.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
|
||||
/**
|
||||
* Load the service configurations from all extensions into the container.
|
||||
*/
|
||||
class phpbb_di_processor_ext implements phpbb_di_processor_interface
|
||||
{
|
||||
private $extension_manager;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $extension_manager The extension manager
|
||||
*/
|
||||
public function __construct($extension_manager)
|
||||
{
|
||||
$this->extension_manager = $extension_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$enabled_exts = $this->extension_manager->all_enabled();
|
||||
foreach ($enabled_exts as $name => $path)
|
||||
{
|
||||
if (file_exists($path . '/config/services.yml'))
|
||||
{
|
||||
$loader = new YamlFileLoader($container, new FileLocator($path . '/config'));
|
||||
$loader->load('services.yml');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
28
phpBB/includes/di/processor/interface.php
Normal file
28
phpBB/includes/di/processor/interface.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
interface phpbb_di_processor_interface
|
||||
{
|
||||
/**
|
||||
* Mutate the container.
|
||||
*
|
||||
* @param ContainerBuilder $container The container
|
||||
*/
|
||||
public function process(ContainerBuilder $container);
|
||||
}
|
|
@ -2231,6 +2231,7 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star
|
|||
function append_sid($url, $params = false, $is_amp = true, $session_id = false)
|
||||
{
|
||||
global $_SID, $_EXTRA_URL, $phpbb_hook;
|
||||
global $phpbb_dispatcher;
|
||||
|
||||
if ($params === '' || (is_array($params) && empty($params)))
|
||||
{
|
||||
|
@ -2238,6 +2239,39 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
|
|||
$params = false;
|
||||
}
|
||||
|
||||
$append_sid_overwrite = false;
|
||||
|
||||
/**
|
||||
* This event can either supplement or override the append_sid() function
|
||||
*
|
||||
* To override this function, the event must set $append_sid_overwrite to
|
||||
* the new URL value, which will be returned following the event
|
||||
*
|
||||
* @event core.append_sid
|
||||
* @var string url The url the session id needs
|
||||
* to be appended to (can have
|
||||
* params)
|
||||
* @var mixed params String or array of additional
|
||||
* url parameters
|
||||
* @var bool is_amp Is url using & (true) or
|
||||
* & (false)
|
||||
* @var bool|string session_id Possibility to use a custom
|
||||
* session id (string) instead of
|
||||
* the global one (false)
|
||||
* @var bool|string append_sid_overwrite Overwrite function (string
|
||||
* URL) or not (false)
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('url', 'params', 'is_amp', 'session_id', 'append_sid_overwrite');
|
||||
extract($phpbb_dispatcher->trigger_event('core.append_sid', compact($vars)));
|
||||
|
||||
if ($append_sid_overwrite)
|
||||
{
|
||||
return $append_sid_overwrite;
|
||||
}
|
||||
|
||||
// The following hook remains for backwards compatibility, though use of
|
||||
// the event above is preferred.
|
||||
// Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropriately.
|
||||
// They could mimic most of what is within this function
|
||||
if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id))
|
||||
|
@ -2821,7 +2855,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
|
|||
$diff = time() - $creation_time;
|
||||
|
||||
// If creation_time and the time() now is zero we can assume it was not a human doing this (the check for if ($diff)...
|
||||
if ($diff && ($diff <= $timespan || $timespan === -1))
|
||||
if (defined('DEBUG_TEST') || $diff && ($diff <= $timespan || $timespan === -1))
|
||||
{
|
||||
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
|
||||
$key = sha1($creation_time . $user->data['user_form_salt'] . $form_name . $token_sid);
|
||||
|
|
|
@ -411,13 +411,33 @@ function strip_bbcode(&$text, $uid = '')
|
|||
function generate_text_for_display($text, $uid, $bitfield, $flags)
|
||||
{
|
||||
static $bbcode;
|
||||
global $phpbb_dispatcher;
|
||||
|
||||
if (!$text)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$censor_text = true;
|
||||
|
||||
/**
|
||||
* Use this event to modify the text before it is parsed
|
||||
*
|
||||
* @event core.modify_text_for_display_before
|
||||
* @var string text The text to parse
|
||||
* @var string uid The BBCode UID
|
||||
* @var string bitfield The BBCode Bitfield
|
||||
* @var int flags The BBCode Flags
|
||||
* @var bool censor_text Whether or not to apply word censors
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('text', 'uid', 'bitfield', 'flags', 'censor_text');
|
||||
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_before', compact($vars)));
|
||||
|
||||
if ($censor_text)
|
||||
{
|
||||
$text = censor_text($text);
|
||||
}
|
||||
|
||||
// Parse bbcode if bbcode uid stored and bbcode enabled
|
||||
if ($uid && ($flags & OPTION_FLAG_BBCODE))
|
||||
|
@ -443,6 +463,19 @@ function generate_text_for_display($text, $uid, $bitfield, $flags)
|
|||
$text = bbcode_nl2br($text);
|
||||
$text = smiley_text($text, !($flags & OPTION_FLAG_SMILIES));
|
||||
|
||||
/**
|
||||
* Use this event to modify the text after it is parsed
|
||||
*
|
||||
* @event core.modify_text_for_display_after
|
||||
* @var string text The text to parse
|
||||
* @var string uid The BBCode UID
|
||||
* @var string bitfield The BBCode Bitfield
|
||||
* @var int flags The BBCode Flags
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('text', 'uid', 'bitfield', 'flags');
|
||||
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_after', compact($vars)));
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
@ -453,7 +486,23 @@ function generate_text_for_display($text, $uid, $bitfield, $flags)
|
|||
*/
|
||||
function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bbcode = false, $allow_urls = false, $allow_smilies = false)
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
global $phpbb_root_path, $phpEx, $phpbb_dispatcher;
|
||||
|
||||
/**
|
||||
* Use this event to modify the text before it is prepared for storage
|
||||
*
|
||||
* @event core.modify_text_for_storage_before
|
||||
* @var string text The text to parse
|
||||
* @var string uid The BBCode UID
|
||||
* @var string bitfield The BBCode Bitfield
|
||||
* @var int flags The BBCode Flags
|
||||
* @var bool allow_bbcode Whether or not to parse BBCode
|
||||
* @var bool allow_urls Whether or not to parse URLs
|
||||
* @var bool allow_smilies Whether or not to parse Smilies
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('text', 'uid', 'bitfield', 'flags', 'allow_bbcode', 'allow_urls', 'allow_smilies');
|
||||
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_before', compact($vars)));
|
||||
|
||||
$uid = $bitfield = '';
|
||||
$flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0);
|
||||
|
@ -482,6 +531,19 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb
|
|||
|
||||
$bitfield = $message_parser->bbcode_bitfield;
|
||||
|
||||
/**
|
||||
* Use this event to modify the text after it is prepared for storage
|
||||
*
|
||||
* @event core.modify_text_for_storage_after
|
||||
* @var string text The text to parse
|
||||
* @var string uid The BBCode UID
|
||||
* @var string bitfield The BBCode Bitfield
|
||||
* @var int flags The BBCode Flags
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('text', 'uid', 'bitfield', 'flags');
|
||||
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_after', compact($vars)));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -491,10 +553,33 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb
|
|||
*/
|
||||
function generate_text_for_edit($text, $uid, $flags)
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
global $phpbb_root_path, $phpEx, $phpbb_dispatcher;
|
||||
|
||||
/**
|
||||
* Use this event to modify the text before it is decoded for editing
|
||||
*
|
||||
* @event core.modify_text_for_edit_before
|
||||
* @var string text The text to parse
|
||||
* @var string uid The BBCode UID
|
||||
* @var int flags The BBCode Flags
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('text', 'uid', 'flags');
|
||||
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_edit_before', compact($vars)));
|
||||
|
||||
decode_message($text, $uid);
|
||||
|
||||
/**
|
||||
* Use this event to modify the text after it is decoded for editing
|
||||
*
|
||||
* @event core.modify_text_for_edit_after
|
||||
* @var string text The text to parse
|
||||
* @var int flags The BBCode Flags
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('text', 'flags');
|
||||
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_edit_after', compact($vars)));
|
||||
|
||||
return array(
|
||||
'allow_bbcode' => ($flags & OPTION_FLAG_BBCODE) ? 1 : 0,
|
||||
'allow_smilies' => ($flags & OPTION_FLAG_SMILIES) ? 1 : 0,
|
||||
|
@ -1175,6 +1260,7 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al
|
|||
function get_username_string($mode, $user_id, $username, $username_colour = '', $guest_username = false, $custom_profile_url = false)
|
||||
{
|
||||
static $_profile_cache;
|
||||
global $phpbb_dispatcher;
|
||||
|
||||
// We cache some common variables we need within this function
|
||||
if (empty($_profile_cache))
|
||||
|
@ -1252,10 +1338,34 @@ function get_username_string($mode, $user_id, $username, $username_colour = '',
|
|||
|
||||
if (($mode == 'full' && !$profile_url) || $mode == 'no_profile')
|
||||
{
|
||||
return str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_noprofile'] : $_profile_cache['tpl_noprofile_colour']);
|
||||
$username_string = str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_noprofile'] : $_profile_cache['tpl_noprofile_colour']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$username_string = str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_profile'] : $_profile_cache['tpl_profile_colour']);
|
||||
}
|
||||
|
||||
return str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_profile'] : $_profile_cache['tpl_profile_colour']);
|
||||
/**
|
||||
* Use this event to change the output of get_username_string()
|
||||
*
|
||||
* @event core.modify_username_string
|
||||
* @var string mode profile|username|colour|full|no_profile
|
||||
* @var int user_id String or array of additional url
|
||||
* parameters
|
||||
* @var string username The user's username
|
||||
* @var string username_colour The user's colour
|
||||
* @var string guest_username Optional parameter to specify the
|
||||
* guest username.
|
||||
* @var string custom_profile_url Optional parameter to specify a
|
||||
* profile url.
|
||||
* @var string username_string The string that has been generated
|
||||
* @var array _profile_cache Array of original return templates
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('mode', 'user_id', 'username', 'username_colour', 'guest_username', 'custom_profile_url', 'username_string', '_profile_cache');
|
||||
extract($phpbb_dispatcher->trigger_event('core.modify_username_string', compact($vars)));
|
||||
|
||||
return $username_string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -522,10 +522,12 @@ function adjust_language_keys_callback($matches)
|
|||
* @param string $dbms The name of the DBAL class to use
|
||||
* @param array $load_extensions Array of additional extensions that should be loaded
|
||||
* @param bool $debug If the debug constants should be enabled by default or not
|
||||
* @param bool $debug_test If the DEBUG_TEST constant should be added
|
||||
* NOTE: Only for use within the testing framework
|
||||
*
|
||||
* @return string The output to write to the file
|
||||
*/
|
||||
function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = false)
|
||||
function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = false, $debug_test = false)
|
||||
{
|
||||
$load_extensions = implode(',', $load_extensions);
|
||||
|
||||
|
@ -540,7 +542,7 @@ function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug =
|
|||
'dbuser' => $data['dbuser'],
|
||||
'dbpasswd' => htmlspecialchars_decode($data['dbpasswd']),
|
||||
'table_prefix' => $data['table_prefix'],
|
||||
'acm_type' => 'file',
|
||||
'acm_type' => 'phpbb_cache_driver_file',
|
||||
'load_extensions' => $load_extensions,
|
||||
);
|
||||
|
||||
|
@ -562,5 +564,10 @@ function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug =
|
|||
$config_data .= "// @define('DEBUG_EXTRA', true);\n";
|
||||
}
|
||||
|
||||
if ($debug_test)
|
||||
{
|
||||
$config_data .= "@define('DEBUG_TEST', true);\n";
|
||||
}
|
||||
|
||||
return $config_data;
|
||||
}
|
||||
|
|
|
@ -162,6 +162,7 @@ function user_update_name($old_name, $new_name)
|
|||
function user_add($user_row, $cp_data = false)
|
||||
{
|
||||
global $db, $user, $auth, $config, $phpbb_root_path, $phpEx;
|
||||
global $phpbb_dispatcher;
|
||||
|
||||
if (empty($user_row['username']) || !isset($user_row['group_id']) || !isset($user_row['user_email']) || !isset($user_row['user_type']))
|
||||
{
|
||||
|
@ -255,6 +256,16 @@ function user_add($user_row, $cp_data = false)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this event to modify the values to be inserted when a user is added
|
||||
*
|
||||
* @event core.user_add_modify_data
|
||||
* @var array sql_ary Array of data to be inserted when a user is added
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('sql_ary');
|
||||
extract($phpbb_dispatcher->trigger_event('core.user_add_modify_data', compact($vars)));
|
||||
|
||||
$sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
||||
$db->sql_query($sql);
|
||||
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
|
||||
/**#@+
|
||||
* @ignore
|
||||
*/
|
||||
|
@ -71,6 +75,9 @@ else
|
|||
|
||||
// Include essential scripts
|
||||
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx);
|
||||
|
||||
require($phpbb_root_path . 'includes/functions.' . $phpEx);
|
||||
|
||||
phpbb_require_updated('includes/functions_content.' . $phpEx, true);
|
||||
|
@ -79,19 +86,23 @@ include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
|||
include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
|
||||
|
||||
$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx");
|
||||
$phpbb_class_loader_ext->register();
|
||||
$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx");
|
||||
$phpbb_class_loader->register();
|
||||
$phpbb_container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config'));
|
||||
$loader->load('services.yml');
|
||||
|
||||
$phpbb_container->setParameter('core.root_path', $phpbb_root_path);
|
||||
$phpbb_container->setParameter('core.php_ext', $phpEx);
|
||||
|
||||
$phpbb_container->setAlias('cache.driver', 'cache.driver.install');
|
||||
|
||||
$phpbb_class_loader = $phpbb_container->get('class_loader');
|
||||
$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
|
||||
|
||||
// set up caching
|
||||
$cache_factory = new phpbb_cache_factory('file');
|
||||
$cache = $cache_factory->get_service();
|
||||
$phpbb_class_loader_ext->set_cache($cache->get_driver());
|
||||
$phpbb_class_loader->set_cache($cache->get_driver());
|
||||
$cache = $phpbb_container->get('cache');
|
||||
|
||||
$phpbb_dispatcher = new phpbb_event_dispatcher();
|
||||
$request = new phpbb_request();
|
||||
$phpbb_dispatcher = $phpbb_container->get('dispatcher');
|
||||
$request = $phpbb_container->get('request');
|
||||
|
||||
// make sure request_var uses this request instance
|
||||
request_var('', 0, false, false, $request); // "dependency injection" for a function
|
||||
|
|
|
@ -269,7 +269,7 @@ $lang = array_merge($lang, array(
|
|||
'MESSAGE_COLOURS' => 'Message colours',
|
||||
'MESSAGE_DELETED' => 'Message successfully deleted.',
|
||||
'MESSAGE_HISTORY' => 'Message history',
|
||||
'MESSAGE_REMOVED_FROM_OUTBOX' => 'This message has been removed by its author before it was delivered.',
|
||||
'MESSAGE_REMOVED_FROM_OUTBOX' => 'This message was deleted by its author.',
|
||||
'MESSAGE_SENT_ON' => 'on',
|
||||
'MESSAGE_STORED' => 'This message has been sent successfully.',
|
||||
'MESSAGE_TO' => 'To',
|
||||
|
|
|
@ -44,6 +44,41 @@ $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var
|
|||
$error = $post_data = array();
|
||||
$current_time = time();
|
||||
|
||||
/**
|
||||
* This event allows you to alter the above parameters, such as submit and mode
|
||||
*
|
||||
* Note: $refresh must be true to retain previously submitted form data.
|
||||
*
|
||||
* Note: The template class will not work properly until $user->setup() is
|
||||
* called, and it has not been called yet. Extensions requiring template
|
||||
* assignments should use an event that comes later in this file.
|
||||
*
|
||||
* @event core.modify_posting_parameters
|
||||
* @var int post_id ID of the post
|
||||
* @var int topic_id ID of the topic
|
||||
* @var int forum_id ID of the forum
|
||||
* @var int draft_id ID of the draft
|
||||
* @var int lastclick Timestamp of when the form was last loaded
|
||||
* @var bool submit Whether or not the form has been submitted
|
||||
* @var bool preview Whether or not the post is being previewed
|
||||
* @var bool save Whether or not a draft is being saved
|
||||
* @var bool load Whether or not a draft is being loaded
|
||||
* @var bool delete Whether or not the post is being deleted
|
||||
* @var bool cancel Whether or not to cancel the form (returns to
|
||||
* viewtopic or viewforum depending on if the user
|
||||
* is posting a new topic or editing a post)
|
||||
* @var bool refresh Whether or not to retain previously submitted data
|
||||
* @var string mode What action to take if the form has been sumitted
|
||||
* post|reply|quote|edit|delete|bump|smilies|popup
|
||||
* @var array error Any error strings; a non-empty array aborts
|
||||
* form submission.
|
||||
* NOTE: Should be actual language strings, NOT
|
||||
* language keys.
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('post_id', 'topic_id', 'forum_id', 'draft_id', 'lastclick', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error');
|
||||
extract($phpbb_dispatcher->trigger_event('core.modify_posting_parameters', compact($vars)));
|
||||
|
||||
// Was cancel pressed? If so then redirect to the appropriate page
|
||||
if ($cancel || ($current_time - $lastclick < 2 && $submit))
|
||||
{
|
||||
|
@ -1376,7 +1411,7 @@ $template->assign_vars(array(
|
|||
'POST_DATE' => ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '',
|
||||
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
|
||||
'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'],
|
||||
'EDIT_REASON' => $post_data['post_edit_reason'],
|
||||
'EDIT_REASON' => $request->variable('edit_reason', ''),
|
||||
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"),
|
||||
'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '',
|
||||
'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup"),
|
||||
|
@ -1417,6 +1452,14 @@ $template->assign_vars(array(
|
|||
'S_HIDDEN_FIELDS' => $s_hidden_fields)
|
||||
);
|
||||
|
||||
/**
|
||||
* This event allows you to modify template variables for the posting screen
|
||||
*
|
||||
* @event core.posting_modify_template_vars
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$phpbb_dispatcher->trigger_event('core.posting_modify_template_vars');
|
||||
|
||||
// Build custom bbcodes array
|
||||
display_custom_bbcodes();
|
||||
|
||||
|
|
|
@ -193,8 +193,12 @@ if ($forum_data['forum_topics_per_page'])
|
|||
// Do the forum Prune thang - cron type job ...
|
||||
if (!$config['use_system_cron'])
|
||||
{
|
||||
$task = $cron->instantiate_task('cron_task_core_prune_forum', $forum_data);
|
||||
if ($task && $task->is_ready())
|
||||
$cron = $phpbb_container->get('cron.manager');
|
||||
|
||||
$task = $cron->find_task('cron.task.core.prune_forum');
|
||||
$task->set_forum_data($forum_data);
|
||||
|
||||
if ($task->is_ready())
|
||||
{
|
||||
$url = $task->get_url();
|
||||
$template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="cron" />');
|
||||
|
|
|
@ -11,6 +11,11 @@ class phpbb_ext_testext_cron_dummy_task extends phpbb_cron_task_base
|
|||
{
|
||||
public static $was_run = 0;
|
||||
|
||||
public function get_name()
|
||||
{
|
||||
return get_class($this);
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
self::$was_run++;
|
||||
|
|
|
@ -11,6 +11,11 @@ class phpbb_cron_task_core_dummy_task extends phpbb_cron_task_base
|
|||
{
|
||||
public static $was_run = 0;
|
||||
|
||||
public function get_name()
|
||||
{
|
||||
return get_class($this);
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
self::$was_run++;
|
||||
|
|
|
@ -11,6 +11,11 @@ class phpbb_cron_task_core_second_dummy_task extends phpbb_cron_task_base
|
|||
{
|
||||
public static $was_run = 0;
|
||||
|
||||
public function get_name()
|
||||
{
|
||||
return get_class($this);
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
self::$was_run++;
|
||||
|
|
|
@ -18,10 +18,10 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
public function setUp()
|
||||
{
|
||||
$this->manager = new phpbb_cron_manager(array(
|
||||
'phpbb_cron_task_core_dummy_task',
|
||||
'phpbb_cron_task_core_second_dummy_task',
|
||||
'phpbb_ext_testext_cron_dummy_task',
|
||||
$this->manager = $this->create_cron_manager(array(
|
||||
new phpbb_cron_task_core_dummy_task(),
|
||||
new phpbb_cron_task_core_second_dummy_task(),
|
||||
new phpbb_ext_testext_cron_dummy_task(),
|
||||
));
|
||||
$this->task_name = 'phpbb_cron_task_core_dummy_task';
|
||||
}
|
||||
|
@ -33,13 +33,6 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals($this->task_name, $task->get_name());
|
||||
}
|
||||
|
||||
public function test_manager_instantiates_task_by_name()
|
||||
{
|
||||
$task = $this->manager->instantiate_task($this->task_name, array());
|
||||
$this->assertInstanceOf('phpbb_cron_task_wrapper', $task);
|
||||
$this->assertEquals($this->task_name, $task->get_name());
|
||||
}
|
||||
|
||||
public function test_manager_finds_all_ready_tasks()
|
||||
{
|
||||
$tasks = $this->manager->find_all_ready_tasks();
|
||||
|
@ -54,10 +47,10 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
|
|||
|
||||
public function test_manager_finds_only_ready_tasks()
|
||||
{
|
||||
$manager = new phpbb_cron_manager(array(
|
||||
'phpbb_cron_task_core_simple_ready',
|
||||
'phpbb_cron_task_core_simple_not_runnable',
|
||||
'phpbb_cron_task_core_simple_should_not_run',
|
||||
$manager = $this->create_cron_manager(array(
|
||||
new phpbb_cron_task_core_simple_ready(),
|
||||
new phpbb_cron_task_core_simple_not_runnable(),
|
||||
new phpbb_cron_task_core_simple_should_not_run(),
|
||||
));
|
||||
$tasks = $manager->find_all_ready_tasks();
|
||||
$task_names = $this->tasks_to_names($tasks);
|
||||
|
@ -69,8 +62,15 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
|
|||
$names = array();
|
||||
foreach ($tasks as $task)
|
||||
{
|
||||
$names[] = get_class($task->task);
|
||||
$names[] = $task->get_name();
|
||||
}
|
||||
return $names;
|
||||
}
|
||||
|
||||
private function create_cron_manager($tasks)
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
return new phpbb_cron_manager($tasks, $phpbb_root_path, $phpEx);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,31 +11,40 @@ class phpbb_cron_task_provider_test extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
public function setUp()
|
||||
{
|
||||
$this->extension_manager = new phpbb_mock_extension_manager(
|
||||
dirname(__FILE__) . '/',
|
||||
array(
|
||||
'testext' => array(
|
||||
'ext_name' => 'testext',
|
||||
'ext_active' => true,
|
||||
'ext_path' => 'ext/testext/'
|
||||
),
|
||||
));
|
||||
$this->provider = new phpbb_cron_task_provider($this->extension_manager);
|
||||
$this->tasks = array(
|
||||
'phpbb_cron_task_core_dummy_task',
|
||||
'phpbb_cron_task_core_second_dummy_task',
|
||||
'phpbb_ext_testext_cron_dummy_task',
|
||||
);
|
||||
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\TaggedContainerInterface');
|
||||
$container
|
||||
->expects($this->once())
|
||||
->method('findTaggedServiceIds')
|
||||
->will($this->returnValue(array_flip($this->tasks)));
|
||||
$container
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnCallback(function ($name) {
|
||||
return new $name;
|
||||
}));
|
||||
|
||||
$this->provider = new phpbb_cron_task_provider($container);
|
||||
}
|
||||
|
||||
public function test_manager_finds_shipped_tasks()
|
||||
{
|
||||
$tasks = array();
|
||||
$task_names = array();
|
||||
foreach ($this->provider as $task)
|
||||
{
|
||||
$tasks[] = $task;
|
||||
$task_names[] = $task->get_name();
|
||||
}
|
||||
sort($tasks);
|
||||
sort($task_names);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'phpbb_cron_task_core_dummy_task',
|
||||
'phpbb_cron_task_core_second_dummy_task',
|
||||
'phpbb_ext_testext_cron_dummy_task',
|
||||
), $tasks);
|
||||
), $task_names);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
class phpbb_cron_task_core_simple_not_runnable extends phpbb_cron_task_base
|
||||
{
|
||||
public function get_name()
|
||||
{
|
||||
return get_class($this);
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
class phpbb_cron_task_core_simple_ready extends phpbb_cron_task_base
|
||||
{
|
||||
public function get_name()
|
||||
{
|
||||
return get_class($this);
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
class phpbb_cron_task_core_simple_should_not_run extends phpbb_cron_task_base
|
||||
{
|
||||
public function get_name()
|
||||
{
|
||||
return get_class($this);
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
}
|
||||
|
|
102
tests/functional/posting_test.php
Normal file
102
tests/functional/posting_test.php
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class phpbb_functional_posting_test extends phpbb_functional_test_case
|
||||
{
|
||||
public function test_post_new_topic()
|
||||
{
|
||||
$this->login();
|
||||
$this->add_lang('posting');
|
||||
|
||||
$crawler = $this->request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid);
|
||||
$this->assertContains($this->lang('POST_TOPIC'), $crawler->filter('html')->text());
|
||||
|
||||
$hidden_fields = array();
|
||||
$hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
|
||||
return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
|
||||
});
|
||||
|
||||
$test_message = 'This is a test topic posted by the testing framework.';
|
||||
$form_data = array(
|
||||
'subject' => 'Test Topic 1',
|
||||
'message' => $test_message,
|
||||
'post' => true,
|
||||
'f' => 2,
|
||||
'mode' => 'post',
|
||||
'sid' => $this->sid,
|
||||
);
|
||||
|
||||
foreach ($hidden_fields as $fields)
|
||||
{
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$form_data[$field['name']] = $field['value'];
|
||||
}
|
||||
}
|
||||
|
||||
// Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened)
|
||||
// is not at least 2 seconds before submission, cancel the form
|
||||
$form_data['lastclick'] = 0;
|
||||
|
||||
// I use a request because the form submission method does not allow you to send data that is not
|
||||
// contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)
|
||||
// Instead, I send it as a request with the submit button "post" set to true.
|
||||
$crawler = $this->client->request('POST', 'posting.php', $form_data);
|
||||
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
|
||||
|
||||
$crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid);
|
||||
$this->assertContains($test_message, $crawler->filter('html')->text());
|
||||
}
|
||||
|
||||
public function test_post_reply()
|
||||
{
|
||||
$this->login();
|
||||
$this->add_lang('posting');
|
||||
|
||||
$crawler = $this->request('GET', 'posting.php?mode=reply&t=2&f=2&sid=' . $this->sid);
|
||||
$this->assertContains($this->lang('POST_REPLY'), $crawler->filter('html')->text());
|
||||
|
||||
$hidden_fields = array();
|
||||
$hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
|
||||
return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
|
||||
});
|
||||
|
||||
$test_message = 'This is a test post posted by the testing framework.';
|
||||
$form_data = array(
|
||||
'subject' => 'Re: Test Topic 1',
|
||||
'message' => $test_message,
|
||||
'post' => true,
|
||||
't' => 2,
|
||||
'f' => 2,
|
||||
'mode' => 'reply',
|
||||
'sid' => $this->sid,
|
||||
);
|
||||
|
||||
foreach ($hidden_fields as $fields)
|
||||
{
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$form_data[$field['name']] = $field['value'];
|
||||
}
|
||||
}
|
||||
|
||||
// For reasoning behind the following command, see the test_post_new_topic() test
|
||||
$form_data['lastclick'] = 0;
|
||||
|
||||
// Submit the post
|
||||
$crawler = $this->client->request('POST', 'posting.php', $form_data);
|
||||
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
|
||||
|
||||
$crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid);
|
||||
$this->assertContains($test_message, $crawler->filter('html')->text());
|
||||
}
|
||||
}
|
|
@ -45,6 +45,9 @@ class phpbb_session_append_sid_test extends phpbb_test_case
|
|||
*/
|
||||
public function test_append_sid($url, $params, $is_amp, $session_id, $expected, $description)
|
||||
{
|
||||
global $phpbb_dispatcher;
|
||||
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
|
||||
$this->assertEquals($expected, append_sid($url, $params, $is_amp, $session_id));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
$this->do_request('create_table', $data);
|
||||
|
||||
$this->do_request('config_file', $data);
|
||||
file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true));
|
||||
file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true, true));
|
||||
|
||||
$this->do_request('final', $data);
|
||||
copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx");
|
||||
|
|
Loading…
Add table
Reference in a new issue