aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/auth/auth.php1
-rw-r--r--phpBB/phpbb/auth/provider/db.php1
-rw-r--r--phpBB/phpbb/captcha/plugins/qa.php4
-rw-r--r--phpBB/phpbb/config/db.php4
-rw-r--r--phpBB/phpbb/content_visibility.php69
-rw-r--r--phpBB/phpbb/controller/helper.php2
-rw-r--r--phpBB/phpbb/db/migration/container_aware_migration.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v30x/release_3_0_13_rc1.php37
-rw-r--r--phpBB/phpbb/db/migration/data/v30x/release_3_0_5_rc1.php10
-rw-r--r--phpBB/phpbb/db/migration/data/v30x/release_3_0_9_rc1.php2
-rw-r--r--phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php41
-rw-r--r--phpBB/phpbb/db/migration/data/v310/postgres_fulltext_drop.php41
-rw-r--r--phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php20
-rw-r--r--phpBB/phpbb/db/migration/data/v310/style_update_p1.php2
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/plupload_last_gc_dynamic.php31
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/profilefield_remove_underscore_from_alpha.php47
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/profilefield_yahoo_update_url.php38
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/update_custom_bbcodes_with_idn.php70
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v312.php31
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v312rc1.php32
-rw-r--r--phpBB/phpbb/db/migration/migration.php6
-rw-r--r--phpBB/phpbb/db/migration/profilefield_base_migration.php6
-rw-r--r--phpBB/phpbb/db/migration/schema_generator.php4
-rw-r--r--phpBB/phpbb/db/migration/tool/module.php1
-rw-r--r--phpBB/phpbb/db/migrator.php54
-rw-r--r--phpBB/phpbb/db/tools/factory.php35
-rw-r--r--phpBB/phpbb/db/tools/tools.php (renamed from phpBB/phpbb/db/tools.php)151
-rw-r--r--phpBB/phpbb/db/tools/tools_interface.php202
-rw-r--r--phpBB/phpbb/di/extension/container_configuration.php8
-rw-r--r--phpBB/phpbb/di/extension/core.php6
-rw-r--r--phpBB/phpbb/error_collector.php17
-rw-r--r--phpBB/phpbb/event/dispatcher.php35
-rw-r--r--phpBB/phpbb/event/dispatcher_interface.php10
-rw-r--r--phpBB/phpbb/event/kernel_exception_subscriber.php59
-rw-r--r--phpBB/phpbb/exception/exception_interface.php29
-rw-r--r--phpBB/phpbb/exception/http_exception.php70
-rw-r--r--phpBB/phpbb/exception/runtime_exception.php52
-rw-r--r--phpBB/phpbb/extension/metadata_manager.php34
-rw-r--r--phpBB/phpbb/log/log.php44
-rw-r--r--phpBB/phpbb/notification/manager.php27
-rw-r--r--phpBB/phpbb/path_helper.php42
-rw-r--r--phpBB/phpbb/profilefields/type/type_bool.php40
-rw-r--r--phpBB/phpbb/profilefields/type/type_string_common.php10
-rw-r--r--phpBB/phpbb/profilefields/type/type_url.php2
-rw-r--r--phpBB/phpbb/request/request.php2
-rw-r--r--phpBB/phpbb/search/fulltext_native.php2
-rw-r--r--phpBB/phpbb/search/fulltext_sphinx.php6
-rw-r--r--phpBB/phpbb/session.php22
-rw-r--r--phpBB/phpbb/template/twig/twig.php8
-rw-r--r--phpBB/phpbb/user_loader.php14
-rw-r--r--phpBB/phpbb/version_helper.php21
51 files changed, 1308 insertions, 230 deletions
diff --git a/phpBB/phpbb/auth/auth.php b/phpBB/phpbb/auth/auth.php
index b59f0e60ec..92c19fd5f7 100644
--- a/phpBB/phpbb/auth/auth.php
+++ b/phpBB/phpbb/auth/auth.php
@@ -929,6 +929,7 @@ class auth
{
global $db, $user, $phpbb_root_path, $phpEx, $phpbb_container;
+ /* @var $provider_collection \phpbb\auth\provider_collection */
$provider_collection = $phpbb_container->get('auth.provider_collection');
$provider = $provider_collection->get_provider();
diff --git a/phpBB/phpbb/auth/provider/db.php b/phpBB/phpbb/auth/provider/db.php
index d8c5fb72de..1adf85ee05 100644
--- a/phpBB/phpbb/auth/provider/db.php
+++ b/phpBB/phpbb/auth/provider/db.php
@@ -155,6 +155,7 @@ class db extends \phpbb\auth\provider\base
// Every auth module is able to define what to do by itself...
if ($show_captcha)
{
+ /* @var $captcha_factory \phpbb\captcha\factory */
$captcha_factory = $this->phpbb_container->get('captcha.factory');
$captcha = $captcha_factory->get_instance($this->config['captcha_plugin']);
$captcha->init(CONFIRM_LOGIN);
diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php
index a7ba994cc3..ca242a96dc 100644
--- a/phpBB/phpbb/captcha/plugins/qa.php
+++ b/phpBB/phpbb/captcha/plugins/qa.php
@@ -115,7 +115,7 @@ class qa
{
global $db;
- $db_tool = new \phpbb\db\tools($db);
+ $db_tool = new \phpbb\db\tools\tools($db);
return $db_tool->sql_table_exists($this->table_captcha_questions);
}
@@ -308,7 +308,7 @@ class qa
{
global $db;
- $db_tool = new \phpbb\db\tools($db);
+ $db_tool = new \phpbb\db\tools\tools($db);
$tables = array($this->table_captcha_questions, $this->table_captcha_answers, $this->table_qa_confirm);
diff --git a/phpBB/phpbb/config/db.php b/phpBB/phpbb/config/db.php
index ef20ebf62a..26489bdd34 100644
--- a/phpBB/phpbb/config/db.php
+++ b/phpBB/phpbb/config/db.php
@@ -145,9 +145,9 @@ class db extends \phpbb\config\config
$sql .= " AND config_value = '" . $this->db->sql_escape($old_value) . "'";
}
- $result = $this->db->sql_query($sql);
+ $this->db->sql_query($sql);
- if (!$this->db->sql_affectedrows($result) && isset($this->config[$key]))
+ if (!$this->db->sql_affectedrows() && isset($this->config[$key]))
{
return false;
}
diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php
index 8bd537586e..c8516d6c85 100644
--- a/phpBB/phpbb/content_visibility.php
+++ b/phpBB/phpbb/content_visibility.php
@@ -44,6 +44,12 @@ class content_visibility
protected $config;
/**
+ * Event dispatcher object
+ * @var \phpbb\event\dispatcher
+ */
+ protected $phpbb_dispatcher;
+
+ /**
* phpBB root path
* @var string
*/
@@ -60,6 +66,7 @@ class content_visibility
*
* @param \phpbb\auth\auth $auth Auth object
* @param \phpbb\config\config $config Config object
+ * @param \phpbb\event\dispatcher $phpbb_dispatcher Event dispatcher object
* @param \phpbb\db\driver\driver_interface $db Database object
* @param \phpbb\user $user User object
* @param string $phpbb_root_path Root path
@@ -69,10 +76,11 @@ class content_visibility
* @param string $topics_table Topics table name
* @param string $users_table Users table name
*/
- public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext, $forums_table, $posts_table, $topics_table, $users_table)
+ public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\event\dispatcher $phpbb_dispatcher, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext, $forums_table, $posts_table, $topics_table, $users_table)
{
$this->auth = $auth;
$this->config = $config;
+ $this->phpbb_dispatcher = $phpbb_dispatcher;
$this->db = $db;
$this->user = $user;
$this->phpbb_root_path = $phpbb_root_path;
@@ -160,6 +168,36 @@ class content_visibility
$approve_forums = array_intersect($forum_ids, array_keys($this->auth->acl_getf('m_approve', true)));
+ $get_forums_visibility_sql_overwrite = false;
+ /**
+ * Allow changing the result of calling get_forums_visibility_sql
+ *
+ * @event core.phpbb_content_visibility_get_forums_visibility_before
+ * @var string where_sql The action the user tried to execute
+ * @var string mode Either "topic" or "post" depending on the query this is being used in
+ * @var array forum_ids Array of forum ids which the posts/topics are limited to
+ * @var string table_alias Table alias to prefix in SQL queries
+ * @var array approve_forums Array of forums where the user has m_approve permissions
+ * @var mixed get_forums_visibility_sql_overwrite If a string, forces the function to return get_forums_visibility_sql_overwrite after executing the event
+ * If false, get_forums_visibility_sql continues normally
+ * It must be either boolean or string
+ * @since 3.1.3-RC1
+ */
+ $vars = array(
+ 'where_sql',
+ 'mode',
+ 'forum_ids',
+ 'table_alias',
+ 'approve_forums',
+ 'get_forums_visibility_sql_overwrite',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_forums_visibility_before', compact($vars)));
+
+ if ($get_forums_visibility_sql_overwrite !== false)
+ {
+ return $get_forums_visibility_sql_overwrite;
+ }
+
if (sizeof($approve_forums))
{
// Remove moderator forums from the rest
@@ -206,6 +244,35 @@ class content_visibility
$approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids);
+ $visibility_sql_overwrite = null;
+
+ /**
+ * Allow changing the result of calling get_global_visibility_sql
+ *
+ * @event core.phpbb_content_visibility_get_global_visibility_before
+ * @var array where_sqls The action the user tried to execute
+ * @var string mode Either "topic" or "post" depending on the query this is being used in
+ * @var array forum_ids Array of forum ids which the posts/topics are limited to
+ * @var string table_alias Table alias to prefix in SQL queries
+ * @var array approve_forums Array of forums where the user has m_approve permissions
+ * @var string visibility_sql_overwrite Forces the function to return an implosion of where_sqls (joined by "OR")
+ * @since 3.1.3-RC1
+ */
+ $vars = array(
+ 'where_sqls',
+ 'mode',
+ 'forum_ids',
+ 'table_alias',
+ 'approve_forums',
+ 'visibility_sql_overwrite',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_global_visibility_before', compact($vars)));
+
+ if ($visibility_sql_overwrite)
+ {
+ return $visibility_sql_overwrite;
+ }
+
if (sizeof($exclude_forum_ids))
{
$where_sqls[] = '(' . $this->db->sql_in_set($table_alias . 'forum_id', $exclude_forum_ids, true) . '
diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php
index 2bc8e6b9d0..76acfacf40 100644
--- a/phpBB/phpbb/controller/helper.php
+++ b/phpBB/phpbb/controller/helper.php
@@ -187,6 +187,8 @@ class helper
* @param string $message The error message
* @param int $code The error code (e.g. 404, 500, 503, etc.)
* @return Response A Response instance
+ *
+ * @deprecated 3.1.3 (To be removed: 3.3.0) Use exceptions instead.
*/
public function error($message, $code = 500)
{
diff --git a/phpBB/phpbb/db/migration/container_aware_migration.php b/phpBB/phpbb/db/migration/container_aware_migration.php
new file mode 100644
index 0000000000..3b4b49b04b
--- /dev/null
+++ b/phpBB/phpbb/db/migration/container_aware_migration.php
@@ -0,0 +1,36 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration;
+
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+* Abstract base class for container aware database migrations.
+*/
+abstract class container_aware_migration extends migration implements ContainerAwareInterface
+{
+ /**
+ * @var ContainerInterface
+ */
+ protected $container;
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setContainer(ContainerInterface $container = null)
+ {
+ $this->container = $container;
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_13_rc1.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_13_rc1.php
new file mode 100644
index 0000000000..9ea68fa862
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_13_rc1.php
@@ -0,0 +1,37 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v30x;
+
+class release_3_0_13_rc1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.0.13-RC1', '>=') && phpbb_version_compare($this->config['version'], '3.1.0-dev', '<');
+ }
+
+ static public function depends_on()
+ {
+ return array('\phpbb\db\migration\data\v30x\release_3_0_12');
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('if', array(
+ phpbb_version_compare($this->config['version'], '3.0.13-RC1', '<'),
+ array('config.update', array('version', '3.0.13-RC1')),
+ )),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_5_rc1.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_5_rc1.php
index 2cc7786046..9f6e3efb91 100644
--- a/phpBB/phpbb/db/migration/data/v30x/release_3_0_5_rc1.php
+++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_5_rc1.php
@@ -13,7 +13,9 @@
namespace phpbb\db\migration\data\v30x;
-class release_3_0_5_rc1 extends \phpbb\db\migration\migration
+use phpbb\db\migration\container_aware_migration;
+
+class release_3_0_5_rc1 extends container_aware_migration
{
public function effectively_installed()
{
@@ -55,9 +57,9 @@ class release_3_0_5_rc1 extends \phpbb\db\migration\migration
public function hash_old_passwords()
{
- global $phpbb_container;
+ /* @var $passwords_manager \phpbb\passwords\manager */
+ $passwords_manager = $this->container->get('passwords.manager');
- $passwords_manager = $phpbb_container->get('passwords.manager');
$sql = 'SELECT user_id, user_password
FROM ' . $this->table_prefix . 'users
WHERE user_pass_convert = 1';
@@ -110,7 +112,7 @@ class release_3_0_5_rc1 extends \phpbb\db\migration\migration
// Select auth_option_ids... the largest id will be preserved
$sql = 'SELECT auth_option_id
FROM ' . ACL_OPTIONS_TABLE . "
- WHERE auth_option = '" . $db->sql_escape($option) . "'
+ WHERE auth_option = '" . $this->db->sql_escape($option) . "'
ORDER BY auth_option_id DESC";
// sql_query_limit not possible here, due to bug in postgresql layer
$result = $this->db->sql_query($sql);
diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_9_rc1.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_9_rc1.php
index 06e46d522f..5f928df47c 100644
--- a/phpBB/phpbb/db/migration/data/v30x/release_3_0_9_rc1.php
+++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_9_rc1.php
@@ -34,7 +34,7 @@ class release_3_0_9_rc1 extends \phpbb\db\migration\migration
// this column was removed from the database updater
// after 3.0.9-RC3 was released. It might still exist
// in 3.0.9-RCX installations and has to be dropped as
- // soon as the db_tools class is capable of properly
+ // soon as the \phpbb\db\tools\tools class is capable of properly
// removing a primary key.
// 'attempt_id' => array('UINT', NULL, 'auto_increment'),
'attempt_ip' => array('VCHAR:40', ''),
diff --git a/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php b/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php
index 4530ebe285..e04a705c91 100644
--- a/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php
+++ b/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php
@@ -15,10 +15,18 @@ namespace phpbb\db\migration\data\v310;
class mysql_fulltext_drop extends \phpbb\db\migration\migration
{
+ protected $indexes;
+
public function effectively_installed()
{
// This migration is irrelevant for all non-MySQL DBMSes.
- return strpos($this->db->get_sql_layer(), 'mysql') === false;
+ if (strpos($this->db->get_sql_layer(), 'mysql') === false)
+ {
+ return true;
+ }
+
+ $this->find_indexes_to_drop();
+ return empty($this->indexes);
}
static public function depends_on()
@@ -30,6 +38,11 @@ class mysql_fulltext_drop extends \phpbb\db\migration\migration
public function update_schema()
{
+ if (empty($this->indexes))
+ {
+ return array();
+ }
+
/*
* Drop FULLTEXT indexes related to MySQL fulltext search.
* Doing so is equivalent to dropping the search index from the ACP.
@@ -40,12 +53,28 @@ class mysql_fulltext_drop extends \phpbb\db\migration\migration
*/
return array(
'drop_keys' => array(
- $this->table_prefix . 'posts' => array(
- 'post_subject',
- 'post_text',
- 'post_content',
- ),
+ $this->table_prefix . 'posts' => $this->indexes,
),
);
}
+
+ public function find_indexes_to_drop()
+ {
+ if ($this->indexes !== null)
+ {
+ return $this->indexes;
+ }
+
+ $this->indexes = array();
+ $potential_keys = array('post_subject', 'post_text', 'post_content');
+ foreach ($potential_keys as $key)
+ {
+ if ($this->db_tools->sql_index_exists($this->table_prefix . 'posts', $key))
+ {
+ $this->indexes[] = $key;
+ }
+ }
+
+ return $this->indexes;
+ }
}
diff --git a/phpBB/phpbb/db/migration/data/v310/postgres_fulltext_drop.php b/phpBB/phpbb/db/migration/data/v310/postgres_fulltext_drop.php
index ea442dfb1b..3457c19478 100644
--- a/phpBB/phpbb/db/migration/data/v310/postgres_fulltext_drop.php
+++ b/phpBB/phpbb/db/migration/data/v310/postgres_fulltext_drop.php
@@ -15,10 +15,18 @@ namespace phpbb\db\migration\data\v310;
class postgres_fulltext_drop extends \phpbb\db\migration\migration
{
+ protected $indexes;
+
public function effectively_installed()
{
// This migration is irrelevant for all non-PostgreSQL DBMSes.
- return strpos($this->db->get_sql_layer(), 'postgres') === false;
+ if (strpos($this->db->get_sql_layer(), 'postgres') === false)
+ {
+ return true;
+ }
+
+ $this->find_indexes_to_drop();
+ return empty($this->indexes);
}
static public function depends_on()
@@ -30,6 +38,11 @@ class postgres_fulltext_drop extends \phpbb\db\migration\migration
public function update_schema()
{
+ if (empty($this->indexes))
+ {
+ return array();
+ }
+
/*
* Drop FULLTEXT indexes related to PostgreSQL fulltext search.
* Doing so is equivalent to dropping the search index from the ACP.
@@ -40,12 +53,28 @@ class postgres_fulltext_drop extends \phpbb\db\migration\migration
*/
return array(
'drop_keys' => array(
- $this->table_prefix . 'posts' => array(
- 'post_subject',
- 'post_text',
- 'post_content',
- ),
+ $this->table_prefix . 'posts' => $this->indexes,
),
);
}
+
+ public function find_indexes_to_drop()
+ {
+ if ($this->indexes !== null)
+ {
+ return $this->indexes;
+ }
+
+ $this->indexes = array();
+ $potential_keys = array('post_subject', 'post_text', 'post_content');
+ foreach ($potential_keys as $key)
+ {
+ if ($this->db_tools->sql_index_exists($this->table_prefix . 'posts', $key))
+ {
+ $this->indexes[] = $key;
+ }
+ }
+
+ return $this->indexes;
+ }
}
diff --git a/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php b/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php
index 58845b88ec..85b90da5fa 100644
--- a/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php
+++ b/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php
@@ -13,12 +13,14 @@
namespace phpbb\db\migration\data\v310;
+use phpbb\db\migration\container_aware_migration;
+
/**
* Migration to convert the Soft Delete MOD for 3.0
*
* https://www.phpbb.com/customise/db/mod/soft_delete/
*/
-class soft_delete_mod_convert extends \phpbb\db\migration\migration
+class soft_delete_mod_convert extends container_aware_migration
{
static public function depends_on()
{
@@ -115,19 +117,11 @@ class soft_delete_mod_convert extends \phpbb\db\migration\migration
}
}
+ /**
+ * @return \phpbb\content_visibility
+ */
protected function get_content_visibility()
{
- return new \phpbb\content_visibility(
- new \phpbb\auth\auth(),
- $this->config,
- $this->db,
- new \phpbb\user('\phpbb\datetime'),
- $this->phpbb_root_path,
- $this->php_ext,
- $this->table_prefix . 'forums',
- $this->table_prefix . 'posts',
- $this->table_prefix . 'topics',
- $this->table_prefix . 'users'
- );
+ return $this->container->get('content.visibility');
}
}
diff --git a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php
index 5a3a1d5de7..e8d3a3af64 100644
--- a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php
+++ b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php
@@ -92,7 +92,7 @@ class style_update_p1 extends \phpbb\db\migration\migration
else
{
$sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id
- FROM ' . STYLES_TABLE . ' s, ' . $this->table_prefix . 'styles_template t, ' . $this->table_prefix . "stles_theme c
+ FROM ' . STYLES_TABLE . ' s, ' . $this->table_prefix . 'styles_template t, ' . $this->table_prefix . "styles_theme c
WHERE t.template_id = s.template_id
AND c.theme_id = s.theme_id";
}
diff --git a/phpBB/phpbb/db/migration/data/v31x/plupload_last_gc_dynamic.php b/phpBB/phpbb/db/migration/data/v31x/plupload_last_gc_dynamic.php
new file mode 100644
index 0000000000..0783d707c5
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/plupload_last_gc_dynamic.php
@@ -0,0 +1,31 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v31x;
+
+class plupload_last_gc_dynamic extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array('\phpbb\db\migration\data\v31x\v312');
+ }
+
+ public function update_data()
+ {
+ return array(
+ // Make plupload_last_gc dynamic.
+ array('config.remove', array('plupload_last_gc')),
+ array('config.add', array('plupload_last_gc', 0, 1)),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/profilefield_remove_underscore_from_alpha.php b/phpBB/phpbb/db/migration/data/v31x/profilefield_remove_underscore_from_alpha.php
new file mode 100644
index 0000000000..60491f8de8
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/profilefield_remove_underscore_from_alpha.php
@@ -0,0 +1,47 @@
+<?php
+
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\db\migration\data\v31x;
+
+class profilefield_remove_underscore_from_alpha extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array('\phpbb\db\migration\data\v31x\v311');
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('custom', array(array($this, 'remove_underscore_from_alpha_validations'))),
+ );
+ }
+
+ public function remove_underscore_from_alpha_validations()
+ {
+ $this->update_validation_rule('[\w]+', '[a-zA-Z0-9]+');
+ $this->update_validation_rule('[\w_]+', '[\w]+');
+ $this->update_validation_rule('[\w.]+', '[a-zA-Z0-9.]+');
+ $this->update_validation_rule('[\w\x20_+\-\[\]]+', '[\w\x20+\-\[\]]+');
+ $this->update_validation_rule('[a-zA-Z][\w\.,\-_]+', '[a-zA-Z][\w\.,\-]+');
+ }
+
+ public function update_validation_rule($old_validation, $new_validation)
+ {
+ $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
+ SET field_validation = '" . $this->db->sql_escape($new_validation) . "'
+ WHERE field_validation = '" . $this->db->sql_escape($old_validation) . "'";
+ $this->db->sql_query($sql);
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/profilefield_yahoo_update_url.php b/phpBB/phpbb/db/migration/data/v31x/profilefield_yahoo_update_url.php
new file mode 100644
index 0000000000..4df9083bdf
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/profilefield_yahoo_update_url.php
@@ -0,0 +1,38 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v31x;
+
+class profilefield_yahoo_update_url extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array('\phpbb\db\migration\data\v31x\v312');
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('custom', array(array($this, 'update_contact_url'))),
+ );
+ }
+
+ public function update_contact_url()
+ {
+ $sql = 'UPDATE ' . $this->table_prefix . "profile_fields
+ SET field_contact_url = 'ymsgr:sendim?%s'
+ WHERE field_name = 'phpbb_yahoo'
+ AND field_contact_url = 'http://edit.yahoo.com/config/send_webmesg?.target=%s&amp;.src=pg'";
+ $this->sql_query($sql);
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/update_custom_bbcodes_with_idn.php b/phpBB/phpbb/db/migration/data/v31x/update_custom_bbcodes_with_idn.php
new file mode 100644
index 0000000000..854ed1f568
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/update_custom_bbcodes_with_idn.php
@@ -0,0 +1,70 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v31x;
+
+class update_custom_bbcodes_with_idn extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v312',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('custom', array(array($this, 'update_bbcodes_table'))),
+ );
+ }
+
+ public function update_bbcodes_table()
+ {
+ if (!class_exists('acp_bbcodes'))
+ {
+ include($this->phpbb_root_path . 'includes/acp/acp_bbcodes.' . $this->php_ext);
+ }
+
+ $bbcodes = new \acp_bbcodes();
+
+ $sql = 'SELECT bbcode_id, bbcode_match, bbcode_tpl
+ FROM ' . BBCODES_TABLE;
+ $result = $this->sql_query($sql);
+
+ $sql_ary = array();
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $data = array();
+ if (preg_match('/(URL|LOCAL_URL|RELATIVE_URL)/', $row['bbcode_match']))
+ {
+ $data = $bbcodes->build_regexp($row['bbcode_match'], $row['bbcode_tpl']);
+ $sql_ary[$row['bbcode_id']] = array(
+ 'first_pass_match' => $data['first_pass_match'],
+ 'first_pass_replace' => $data['first_pass_replace'],
+ 'second_pass_match' => $data['second_pass_match'],
+ 'second_pass_replace' => $data['second_pass_replace']
+ );
+ }
+ }
+ $this->db->sql_freeresult($result);
+
+ foreach ($sql_ary as $bbcode_id => $bbcode_data)
+ {
+ $sql = 'UPDATE ' . BBCODES_TABLE . '
+ SET ' . $this->db->sql_build_array('UPDATE', $bbcode_data) . '
+ WHERE bbcode_id = ' . (int) $bbcode_id;
+ $this->sql_query($sql);
+ }
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v312.php b/phpBB/phpbb/db/migration/data/v31x/v312.php
new file mode 100644
index 0000000000..bf49935f4d
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v312.php
@@ -0,0 +1,31 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v31x;
+
+class v312 extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v312rc1',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.2')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v312rc1.php b/phpBB/phpbb/db/migration/data/v31x/v312rc1.php
new file mode 100644
index 0000000000..d4b133fc01
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v312rc1.php
@@ -0,0 +1,32 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v31x;
+
+class v312rc1 extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v311',
+ '\phpbb\db\migration\data\v31x\m_softdelete_global',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.2-RC1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/migration.php b/phpBB/phpbb/db/migration/migration.php
index 5f120333e1..2304c8e44c 100644
--- a/phpBB/phpbb/db/migration/migration.php
+++ b/phpBB/phpbb/db/migration/migration.php
@@ -28,7 +28,7 @@ abstract class migration
/** @var \phpbb\db\driver\driver_interface */
protected $db;
- /** @var \phpbb\db\tools */
+ /** @var \phpbb\db\tools\tools_interface */
protected $db_tools;
/** @var string */
@@ -51,12 +51,12 @@ abstract class migration
*
* @param \phpbb\config\config $config
* @param \phpbb\db\driver\driver_interface $db
- * @param \phpbb\db\tools $db_tools
+ * @param \phpbb\db\tools\tools_interface $db_tools
* @param string $phpbb_root_path
* @param string $php_ext
* @param string $table_prefix
*/
- public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools $db_tools, $phpbb_root_path, $php_ext, $table_prefix)
+ public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $phpbb_root_path, $php_ext, $table_prefix)
{
$this->config = $config;
$this->db = $db;
diff --git a/phpBB/phpbb/db/migration/profilefield_base_migration.php b/phpBB/phpbb/db/migration/profilefield_base_migration.php
index 9000949a7d..3f26a4998c 100644
--- a/phpBB/phpbb/db/migration/profilefield_base_migration.php
+++ b/phpBB/phpbb/db/migration/profilefield_base_migration.php
@@ -13,7 +13,7 @@
namespace phpbb\db\migration;
-abstract class profilefield_base_migration extends \phpbb\db\migration\migration
+abstract class profilefield_base_migration extends container_aware_migration
{
protected $profilefield_name;
@@ -237,8 +237,8 @@ abstract class profilefield_base_migration extends \phpbb\db\migration\migration
if ($profile_row === null)
{
- global $phpbb_container;
- $manager = $phpbb_container->get('profilefields.manager');
+ /* @var $manager \phpbb\profilefields\manager */
+ $manager = $this->container->get('profilefields.manager');
$profile_row = $manager->build_insert_sql_array(array());
}
diff --git a/phpBB/phpbb/db/migration/schema_generator.php b/phpBB/phpbb/db/migration/schema_generator.php
index 91d8307d91..7003844bc4 100644
--- a/phpBB/phpbb/db/migration/schema_generator.php
+++ b/phpBB/phpbb/db/migration/schema_generator.php
@@ -24,7 +24,7 @@ class schema_generator
/** @var \phpbb\db\driver\driver_interface */
protected $db;
- /** @var \phpbb\db\tools */
+ /** @var \phpbb\db\tools\tools_interface */
protected $db_tools;
/** @var array */
@@ -48,7 +48,7 @@ class schema_generator
/**
* Constructor
*/
- public function __construct(array $class_names, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools $db_tools, $phpbb_root_path, $php_ext, $table_prefix)
+ public function __construct(array $class_names, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $phpbb_root_path, $php_ext, $table_prefix)
{
$this->config = $config;
$this->db = $db;
diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php
index db43046a95..035625b095 100644
--- a/phpBB/phpbb/db/migration/tool/module.php
+++ b/phpBB/phpbb/db/migration/tool/module.php
@@ -475,6 +475,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
if (!class_exists('acp_modules'))
{
include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
+ $this->user->add_lang('acp/modules');
}
$acp_modules = new \acp_modules();
$module = $acp_modules->get_module_infos($basename, $class, true);
diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php
index d03496eae3..6902913c64 100644
--- a/phpBB/phpbb/db/migrator.php
+++ b/phpBB/phpbb/db/migrator.php
@@ -13,18 +13,26 @@
namespace phpbb\db;
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
/**
* The migrator is responsible for applying new migrations in the correct order.
*/
class migrator
{
+ /**
+ * @var ContainerInterface
+ */
+ protected $container;
+
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\db\driver\driver_interface */
protected $db;
- /** @var \phpbb\db\tools */
+ /** @var \phpbb\db\tools\tools_interface */
protected $db_tools;
/** @var \phpbb\db\migration\helper */
@@ -77,15 +85,16 @@ class migrator
/**
* The output handler. A null handler is configured by default.
*
- * @var migrator_output_handler
+ * @var migrator_output_handler_interface
*/
public $output_handler;
/**
* Constructor of the database migrator
*/
- public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tools, \phpbb\db\migration\helper $helper)
+ public function __construct(ContainerInterface $container, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tools, \phpbb\db\migration\helper $helper)
{
+ $this->container = $container;
$this->config = $config;
$this->db = $db;
$this->db_tools = $db_tools;
@@ -172,6 +181,18 @@ class migrator
*/
public function update()
{
+ $this->container->get('dispatcher')->disable();
+ $this->update_do();
+ $this->container->get('dispatcher')->enable();
+ }
+
+ /**
+ * Effectively runs a single update step from the next migration to be applied.
+ *
+ * @return null
+ */
+ protected function update_do()
+ {
foreach ($this->migrations as $name)
{
if (!isset($this->migration_state[$name]) ||
@@ -317,7 +338,7 @@ class migrator
catch (\phpbb\db\migration\exception $e)
{
// Revert the schema changes
- $this->revert($name);
+ $this->revert_do($name);
// Rethrow exception
throw $e;
@@ -337,10 +358,22 @@ class migrator
* check if revert() needs to be called again use the migration_state() method.
*
* @param string $migration String migration name to revert (including any that depend on this migration)
- * @return null
*/
public function revert($migration)
{
+ $this->container->get('dispatcher')->disable();
+ $this->revert_do($migration);
+ $this->container->get('dispatcher')->enable();
+ }
+
+ /**
+ * Effectively runs a single revert step from the last migration installed
+ *
+ * @param string $migration String migration name to revert (including any that depend on this migration)
+ * @return null
+ */
+ protected function revert_do($migration)
+ {
if (!isset($this->migration_state[$migration]))
{
// Not installed
@@ -351,7 +384,7 @@ class migrator
{
if (!empty($state['migration_depends_on']) && in_array($migration, $state['migration_depends_on']))
{
- $this->revert($name);
+ $this->revert_do($name);
}
}
@@ -742,7 +775,14 @@ class migrator
*/
protected function get_migration($name)
{
- return new $name($this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix);
+ $migration = new $name($this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix);
+
+ if ($migration instanceof ContainerAwareInterface)
+ {
+ $migration->setContainer($this->container);
+ }
+
+ return $migration;
}
/**
diff --git a/phpBB/phpbb/db/tools/factory.php b/phpBB/phpbb/db/tools/factory.php
new file mode 100644
index 0000000000..60db2ade03
--- /dev/null
+++ b/phpBB/phpbb/db/tools/factory.php
@@ -0,0 +1,35 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\tools;
+
+/**
+ * A factory which serves the suitable tools instance for the given dbal
+ */
+class factory
+{
+ /**
+ * @param mixed $db_driver
+ * @param bool $return_statements
+ * @return \phpbb\db\tools\tools_interface
+ */
+ public function get($db_driver, $return_statements = false)
+ {
+ if ($db_driver instanceof \phpbb\db\driver\driver_interface)
+ {
+ return new \phpbb\db\tools\tools($db_driver, $return_statements);
+ }
+
+ throw new \InvalidArgumentException('Invalid database driver given');
+ }
+}
diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools/tools.php
index c8d25f23a2..152ec6b00f 100644
--- a/phpBB/phpbb/db/tools.php
+++ b/phpBB/phpbb/db/tools/tools.php
@@ -11,13 +11,13 @@
*
*/
-namespace phpbb\db;
+namespace phpbb\db\tools;
/**
* Database Tools for handling cross-db actions such as altering columns, etc.
* Currently not supported is returning SQL for creating tables.
*/
-class tools
+class tools implements tools_interface
{
/**
* Current sql layer
@@ -371,10 +371,8 @@ class tools
}
/**
- * Gets a list of tables in the database.
- *
- * @return array Array of table names (all lower case)
- */
+ * {@inheritDoc}
+ */
function sql_list_tables()
{
switch ($this->db->get_sql_layer())
@@ -431,12 +429,8 @@ class tools
}
/**
- * Check if table exists
- *
- *
- * @param string $table_name The table name to check for
- * @return bool true if table exists, else false
- */
+ * {@inheritDoc}
+ */
function sql_table_exists($table_name)
{
$this->db->sql_return_on_error(true);
@@ -453,12 +447,8 @@ class tools
}
/**
- * Create SQL Table
- *
- * @param string $table_name The table name to create
- * @param array $table_data Array containing table data.
- * @return array Statements if $return_statements is true.
- */
+ * {@inheritDoc}
+ */
function sql_create_table($table_name, $table_data)
{
// holds the DDL for a column
@@ -679,27 +669,8 @@ class tools
}
/**
- * Handle passed database update array.
- * Expected structure...
- * Key being one of the following
- * drop_tables: Drop tables
- * add_tables: Add tables
- * change_columns: Column changes (only type, not name)
- * add_columns: Add columns to a table
- * drop_keys: Dropping keys
- * drop_columns: Removing/Dropping columns
- * add_primary_keys: adding primary keys
- * add_unique_index: adding an unique index
- * add_index: adding an index (can be column:index_size if you need to provide size)
- *
- * The values are in this format:
- * {TABLE NAME} => array(
- * {COLUMN NAME} => array({COLUMN TYPE}, {DEFAULT VALUE}, {OPTIONAL VARIABLES}),
- * {KEY/INDEX NAME} => array({COLUMN NAMES}),
- * )
- *
- * For more information have a look at /develop/create_schema_files.php (only available through SVN)
- */
+ * {@inheritDoc}
+ */
function perform_schema_changes($schema_changes)
{
if (empty($schema_changes))
@@ -1079,13 +1050,9 @@ class tools
}
/**
- * Gets a list of columns of a table.
- *
- * @param string $table Table name
- *
- * @return array Array of column names (all lower case)
- */
- function sql_list_columns($table)
+ * {@inheritDoc}
+ */
+ function sql_list_columns($table_name)
{
$columns = array();
@@ -1093,7 +1060,7 @@ class tools
{
case 'mysql_40':
case 'mysql_41':
- $sql = "SHOW COLUMNS FROM $table";
+ $sql = "SHOW COLUMNS FROM $table_name";
break;
// PostgreSQL has a way of doing this in a much simpler way but would
@@ -1101,7 +1068,7 @@ class tools
case 'postgres':
$sql = "SELECT a.attname
FROM pg_class c, pg_attribute a
- WHERE c.relname = '{$table}'
+ WHERE c.relname = '{$table_name}'
AND a.attnum > 0
AND a.attrelid = c.oid";
break;
@@ -1113,13 +1080,13 @@ class tools
$sql = "SELECT c.name
FROM syscolumns c
LEFT JOIN sysobjects o ON c.id = o.id
- WHERE o.name = '{$table}'";
+ WHERE o.name = '{$table_name}'";
break;
case 'oracle':
$sql = "SELECT column_name
FROM user_tab_columns
- WHERE LOWER(table_name) = '" . strtolower($table) . "'";
+ WHERE LOWER(table_name) = '" . strtolower($table_name) . "'";
break;
case 'sqlite':
@@ -1127,7 +1094,7 @@ class tools
$sql = "SELECT sql
FROM sqlite_master
WHERE type = 'table'
- AND name = '{$table}'";
+ AND name = '{$table_name}'";
$result = $this->db->sql_query($sql);
@@ -1173,28 +1140,18 @@ class tools
}
/**
- * Check whether a specified column exist in a table
- *
- * @param string $table Table to check
- * @param string $column_name Column to check
- *
- * @return bool True if column exists, false otherwise
- */
- function sql_column_exists($table, $column_name)
+ * {@inheritDoc}
+ */
+ function sql_column_exists($table_name, $column_name)
{
- $columns = $this->sql_list_columns($table);
+ $columns = $this->sql_list_columns($table_name);
return isset($columns[$column_name]);
}
/**
- * Check if a specified index exists in table. Does not return PRIMARY KEY and UNIQUE indexes.
- *
- * @param string $table_name Table to check the index at
- * @param string $index_name The index name to check
- *
- * @return bool True if index exists, else false
- */
+ * {@inheritDoc}
+ */
function sql_index_exists($table_name, $index_name)
{
if ($this->sql_layer == 'mssql' || $this->sql_layer == 'mssqlnative')
@@ -1285,13 +1242,8 @@ class tools
}
/**
- * Check if a specified index exists in table. Does not return PRIMARY KEY indexes.
- *
- * @param string $table_name Table to check the index at
- * @param string $index_name The index name to check
- *
- * @return bool True if index exists, else false
- */
+ * {@inheritDoc}
+ */
function sql_unique_index_exists($table_name, $index_name)
{
if ($this->sql_layer == 'mssql' || $this->sql_layer == 'mssqlnative')
@@ -1574,7 +1526,15 @@ class tools
}
else
{
- $default_val = "'" . $column_data[1] . "'";
+ // Integers need to have 0 instead of empty string as default
+ if (strpos($column_type, 'INT') === 0)
+ {
+ $default_val = '0';
+ }
+ else
+ {
+ $default_val = "'" . $column_data[1] . "'";
+ }
$return_array['null'] = 'NULL';
$sql .= 'NULL ';
}
@@ -1684,8 +1644,8 @@ class tools
}
/**
- * Add new column
- */
+ * {@inheritDoc}
+ */
function sql_column_add($table_name, $column_name, $column_data, $inline = false)
{
$column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data);
@@ -1802,8 +1762,8 @@ class tools
}
/**
- * Drop column
- */
+ * {@inheritDoc}
+ */
function sql_column_remove($table_name, $column_name, $inline = false)
{
$statements = array();
@@ -1931,8 +1891,8 @@ class tools
}
/**
- * Drop Index
- */
+ * {@inheritDoc}
+ */
function sql_index_drop($table_name, $index_name)
{
$statements = array();
@@ -1961,8 +1921,8 @@ class tools
}
/**
- * Drop Table
- */
+ * {@inheritDoc}
+ */
function sql_table_drop($table_name)
{
$statements = array();
@@ -2014,8 +1974,8 @@ class tools
}
/**
- * Add primary key
- */
+ * {@inheritDoc}
+ */
function sql_create_primary_key($table_name, $column, $inline = false)
{
$statements = array();
@@ -2098,8 +2058,8 @@ class tools
}
/**
- * Add unique index
- */
+ * {@inheritDoc}
+ */
function sql_create_unique_index($table_name, $index_name, $column)
{
$statements = array();
@@ -2135,8 +2095,8 @@ class tools
}
/**
- * Add index
- */
+ * {@inheritDoc}
+ */
function sql_create_index($table_name, $index_name, $column)
{
$statements = array();
@@ -2175,7 +2135,7 @@ class tools
}
// no break
case 'mysql_41':
- $statements[] = 'ALTER TABLE ' . $table_name . ' ADD INDEX ' . $index_name . '(' . implode(', ', $column) . ')';
+ $statements[] = 'ALTER TABLE ' . $table_name . ' ADD INDEX ' . $index_name . ' (' . implode(', ', $column) . ')';
break;
case 'mssql':
@@ -2188,11 +2148,8 @@ class tools
}
/**
- * List all of the indices that belong to a table,
- * does not count:
- * * UNIQUE indices
- * * PRIMARY keys
- */
+ * {@inheritDoc}
+ */
function sql_list_index($table_name)
{
$index_array = array();
@@ -2287,8 +2244,8 @@ class tools
}
/**
- * Change column type (not name!)
- */
+ * {@inheritDoc}
+ */
function sql_column_change($table_name, $column_name, $column_data, $inline = false)
{
$original_column_data = $column_data;
diff --git a/phpBB/phpbb/db/tools/tools_interface.php b/phpBB/phpbb/db/tools/tools_interface.php
new file mode 100644
index 0000000000..f153f73a54
--- /dev/null
+++ b/phpBB/phpbb/db/tools/tools_interface.php
@@ -0,0 +1,202 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\tools;
+
+/**
+ * Interface for a Database Tools for handling cross-db actions such as altering columns, etc.
+ */
+interface tools_interface
+{
+ /**
+ * Handle passed database update array.
+ * Expected structure...
+ * Key being one of the following
+ * drop_tables: Drop tables
+ * add_tables: Add tables
+ * change_columns: Column changes (only type, not name)
+ * add_columns: Add columns to a table
+ * drop_keys: Dropping keys
+ * drop_columns: Removing/Dropping columns
+ * add_primary_keys: adding primary keys
+ * add_unique_index: adding an unique index
+ * add_index: adding an index (can be column:index_size if you need to provide size)
+ *
+ * The values are in this format:
+ * {TABLE NAME} => array(
+ * {COLUMN NAME} => array({COLUMN TYPE}, {DEFAULT VALUE}, {OPTIONAL VARIABLES}),
+ * {KEY/INDEX NAME} => array({COLUMN NAMES}),
+ * )
+ *
+ *
+ * @param array $schema_changes
+ * @return null
+ */
+ public function perform_schema_changes($schema_changes);
+
+ /**
+ * Gets a list of tables in the database.
+ *
+ * @return array Array of table names (all lower case)
+ */
+ public function sql_list_tables();
+
+ /**
+ * Check if table exists
+ *
+ * @param string $table_name The table name to check for
+ * @return bool true if table exists, else false
+ */
+ public function sql_table_exists($table_name);
+
+ /**
+ * Create SQL Table
+ *
+ * @param string $table_name The table name to create
+ * @param array $table_data Array containing table data.
+ * @return array|true Statements to run, or true if the statements have been executed
+ */
+ public function sql_create_table($table_name, $table_data);
+
+ /**
+ * Drop Table
+ *
+ * @param string $table_name The table name to drop
+ * @return array|true Statements to run, or true if the statements have been executed
+ */
+ public function sql_table_drop($table_name);
+
+ /**
+ * Gets a list of columns of a table.
+ *
+ * @param string $table_name Table name
+ * @return array Array of column names (all lower case)
+ */
+ public function sql_list_columns($table_name);
+
+ /**
+ * Check whether a specified column exist in a table
+ *
+ * @param string $table_name Table to check
+ * @param string $column_name Column to check
+ * @return bool True if column exists, false otherwise
+ */
+ public function sql_column_exists($table_name, $column_name);
+
+ /**
+ * Add new column
+ *
+ * @param string $table_name Table to modify
+ * @param string $column_name Name of the column to add
+ * @param array $column_data Column data
+ * @param bool $inline Whether the query should actually be run,
+ * or return a string for adding the column
+ * @return array|true Statements to run, or true if the statements have been executed
+ */
+ public function sql_column_add($table_name, $column_name, $column_data, $inline = false);
+
+ /**
+ * Change column type (not name!)
+ *
+ * @param string $table_name Table to modify
+ * @param string $column_name Name of the column to modify
+ * @param array $column_data Column data
+ * @param bool $inline Whether the query should actually be run,
+ * or return a string for modifying the column
+ * @return array|true Statements to run, or true if the statements have been executed
+ */
+ public function sql_column_change($table_name, $column_name, $column_data, $inline = false);
+
+ /**
+ * Drop column
+ *
+ * @param string $table_name Table to modify
+ * @param string $column_name Name of the column to drop
+ * @param bool $inline Whether the query should actually be run,
+ * or return a string for deleting the column
+ * @return array|true Statements to run, or true if the statements have been executed
+ */
+ public function sql_column_remove($table_name, $column_name, $inline = false);
+
+ /**
+ * List all of the indices that belong to a table
+ *
+ * NOTE: does not list
+ * - UNIQUE indices
+ * - PRIMARY keys
+ *
+ * @param string $table_name Table to check
+ * @return array Array with index names
+ */
+ public function sql_list_index($table_name);
+
+ /**
+ * Check if a specified index exists in table. Does not return PRIMARY KEY and UNIQUE indexes.
+ *
+ * @param string $table_name Table to check the index at
+ * @param string $index_name The index name to check
+ * @return bool True if index exists, else false
+ */
+ public function sql_index_exists($table_name, $index_name);
+
+ /**
+ * Add index
+ *
+ * @param string $table_name Table to modify
+ * @param string $index_name Name of the index to create
+ * @param string|array $column Either a string with a column name, or an array with columns
+ * @return array|true Statements to run, or true if the statements have been executed
+ */
+ public function sql_create_index($table_name, $index_name, $column);
+
+ /**
+ * Drop Index
+ *
+ * @param string $table_name Table to modify
+ * @param string $index_name Name of the index to delete
+ * @return array|true Statements to run, or true if the statements have been executed
+ */
+ public function sql_index_drop($table_name, $index_name);
+
+ /**
+ * Check if a specified index exists in table.
+ *
+ * NOTE: Does not return normal and PRIMARY KEY indexes
+ *
+ * @param string $table_name Table to check the index at
+ * @param string $index_name The index name to check
+ * @return bool True if index exists, else false
+ */
+ public function sql_unique_index_exists($table_name, $index_name);
+
+ /**
+ * Add unique index
+ *
+ * @param string $table_name Table to modify
+ * @param string $index_name Name of the unique index to create
+ * @param string|array $column Either a string with a column name, or an array with columns
+ * @return array|true Statements to run, or true if the statements have been executed
+ */
+ public function sql_create_unique_index($table_name, $index_name, $column);
+
+ /**
+ * Add primary key
+ *
+ * @param string $table_name Table to modify
+ * @param string|array $column Either a string with a column name, or an array with columns
+ * @param bool $inline Whether the query should actually be run,
+ * or return a string for creating the key
+ * @return array|true Statements to run, or true if the statements have been executed
+ */
+ public function sql_create_primary_key($table_name, $column, $inline = false);
+}
diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php
index 1f1c077472..ee58ec2b74 100644
--- a/phpBB/phpbb/di/extension/container_configuration.php
+++ b/phpBB/phpbb/di/extension/container_configuration.php
@@ -30,7 +30,13 @@ class container_configuration implements ConfigurationInterface
$rootNode = $treeBuilder->root('core');
$rootNode
->children()
- ->booleanNode('require_dev_dependencies')->defaultValue(false)->end()
+ ->booleanNode('require_dev_dependencies')->defaultValue(false)->end()
+ ->arrayNode('twig')
+ ->addDefaultsIfNotSet()
+ ->children()
+ ->booleanNode('enable_debug_extension')->defaultValue(false)->end()
+ ->end()
+ ->end()
->end()
;
return $treeBuilder;
diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php
index 72d46fb05b..451efc8e35 100644
--- a/phpBB/phpbb/di/extension/core.php
+++ b/phpBB/phpbb/di/extension/core.php
@@ -67,6 +67,12 @@ class core extends Extension
);
}
}
+
+ if ($config['twig']['enable_debug_extension'])
+ {
+ $definition = $container->getDefinition('template.twig.extensions.debug');
+ $definition->addTag('twig.extension');
+ }
}
/**
diff --git a/phpBB/phpbb/error_collector.php b/phpBB/phpbb/error_collector.php
index 7141f83174..bf8efd1065 100644
--- a/phpBB/phpbb/error_collector.php
+++ b/phpBB/phpbb/error_collector.php
@@ -16,15 +16,28 @@ namespace phpbb;
class error_collector
{
var $errors;
+ var $error_types;
- function __construct()
+ /**
+ * Constructor.
+ *
+ * The variable $error_types may be set to a mask of PHP error types that
+ * the collector should keep, e.g. `E_ALL`. If unset, the current value of
+ * the error_reporting() function will be used to determine which errors
+ * the collector will keep.
+ *
+ * @see PHPBB3-13306
+ * @param int|null $error_types
+ */
+ function __construct($error_types = null)
{
$this->errors = array();
+ $this->error_types = $error_types;
}
function install()
{
- set_error_handler(array(&$this, 'error_handler'));
+ set_error_handler(array(&$this, 'error_handler'), ($this->error_types !== null) ? $this->error_types : error_reporting());
}
function uninstall()
diff --git a/phpBB/phpbb/event/dispatcher.php b/phpBB/phpbb/event/dispatcher.php
index 9a786022c2..1c4abeb108 100644
--- a/phpBB/phpbb/event/dispatcher.php
+++ b/phpBB/phpbb/event/dispatcher.php
@@ -14,6 +14,7 @@
namespace phpbb\event;
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
+use Symfony\Component\EventDispatcher\Event;
/**
* Extension of the Symfony2 EventDispatcher
@@ -32,6 +33,11 @@ use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
class dispatcher extends ContainerAwareEventDispatcher implements dispatcher_interface
{
/**
+ * @var bool
+ */
+ protected $disabled = false;
+
+ /**
* {@inheritdoc}
*/
public function trigger_event($eventName, $data = array())
@@ -40,4 +46,33 @@ class dispatcher extends ContainerAwareEventDispatcher implements dispatcher_int
$this->dispatch($eventName, $event);
return $event->get_data_filtered(array_keys($data));
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function dispatch($eventName, Event $event = null)
+ {
+ if ($this->disabled)
+ {
+ return $event;
+ }
+
+ return parent::dispatch($eventName, $event);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function disable()
+ {
+ $this->disabled = true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function enable()
+ {
+ $this->disabled = false;
+ }
}
diff --git a/phpBB/phpbb/event/dispatcher_interface.php b/phpBB/phpbb/event/dispatcher_interface.php
index 50a3ef9101..c66aa98260 100644
--- a/phpBB/phpbb/event/dispatcher_interface.php
+++ b/phpBB/phpbb/event/dispatcher_interface.php
@@ -37,4 +37,14 @@ interface dispatcher_interface extends \Symfony\Component\EventDispatcher\EventD
* @return mixed
*/
public function trigger_event($eventName, $data = array());
+
+ /**
+ * Disable the event dispatcher.
+ */
+ public function disable();
+
+ /**
+ * Enable the event dispatcher.
+ */
+ public function enable();
}
diff --git a/phpBB/phpbb/event/kernel_exception_subscriber.php b/phpBB/phpbb/event/kernel_exception_subscriber.php
index 44e87507f9..eb7831ad34 100644
--- a/phpBB/phpbb/event/kernel_exception_subscriber.php
+++ b/phpBB/phpbb/event/kernel_exception_subscriber.php
@@ -14,9 +14,10 @@
namespace phpbb\event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\HttpFoundation\JsonResponse;
+use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
-use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpFoundation\Response;
class kernel_exception_subscriber implements EventSubscriberInterface
@@ -53,23 +54,55 @@ class kernel_exception_subscriber implements EventSubscriberInterface
*/
public function on_kernel_exception(GetResponseForExceptionEvent $event)
{
- page_header($this->user->lang('INFORMATION'));
-
$exception = $event->getException();
- $this->template->assign_vars(array(
- 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'),
- 'MESSAGE_TEXT' => $exception->getMessage(),
- ));
+ $message = $exception->getMessage();
+
+ if ($exception instanceof \phpbb\exception\exception_interface)
+ {
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($message), $exception->get_parameters()));
+ }
+
+ if (!$event->getRequest()->isXmlHttpRequest())
+ {
+ page_header($this->user->lang('INFORMATION'));
+
+ $this->template->assign_vars(array(
+ 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'),
+ 'MESSAGE_TEXT' => $message,
+ ));
+
+ $this->template->set_filenames(array(
+ 'body' => 'message_body.html',
+ ));
+
+ page_footer(true, false, false);
+
+ $response = new Response($this->template->assign_display('body'), 500);
+ }
+ else
+ {
+ $data = array();
+
+ if (!empty($message))
+ {
+ $data['message'] = $message;
+ }
+
+ if (defined('DEBUG'))
+ {
+ $data['trace'] = $exception->getTrace();
+ }
- $this->template->set_filenames(array(
- 'body' => 'message_body.html',
- ));
+ $response = new JsonResponse($data, 500);
+ }
- page_footer(true, false, false);
+ if ($exception instanceof HttpExceptionInterface)
+ {
+ $response->setStatusCode($exception->getStatusCode());
+ $response->headers->add($exception->getHeaders());
+ }
- $status_code = $exception instanceof HttpException ? $exception->getStatusCode() : 500;
- $response = new Response($this->template->assign_display('body'), $status_code);
$event->setResponse($response);
}
diff --git a/phpBB/phpbb/exception/exception_interface.php b/phpBB/phpbb/exception/exception_interface.php
new file mode 100644
index 0000000000..e8526a35f5
--- /dev/null
+++ b/phpBB/phpbb/exception/exception_interface.php
@@ -0,0 +1,29 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\exception;
+
+/**
+ * Interface exception_interface
+ *
+ * Define an exception which support a language var as message.
+ */
+interface exception_interface
+{
+ /**
+ * Return the arguments associated with the message if it's a language var.
+ *
+ * @return array
+ */
+ public function get_parameters();
+}
diff --git a/phpBB/phpbb/exception/http_exception.php b/phpBB/phpbb/exception/http_exception.php
new file mode 100644
index 0000000000..0e6ffe4f59
--- /dev/null
+++ b/phpBB/phpbb/exception/http_exception.php
@@ -0,0 +1,70 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\exception;
+
+use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
+
+/**
+ * Class http_exception
+ */
+class http_exception extends runtime_exception implements HttpExceptionInterface
+{
+ /**
+ * Http status code.
+ *
+ * @var integer
+ */
+ private $status_code;
+
+ /**
+ * Additional headers to set in the response.
+ *
+ * @var array
+ */
+ private $headers;
+
+ /**
+ * Constructor
+ *
+ * @param integer $status_code The http status code.
+ * @param string $message The Exception message to throw (must be a language variable).
+ * @param array $parameters The parameters to use with the language var.
+ * @param \Exception $previous The previous exception used for the exception chaining.
+ * @param array $headers Additional headers to set in the response.
+ * @param integer $code The Exception code.
+ */
+ public function __construct($status_code, $message = "", array $parameters = array(), \Exception $previous = null, array $headers = array(), $code = 0)
+ {
+ $this->status_code = $status_code;
+ $this->headers = $headers;
+
+ parent::__construct($message, $parameters, $previous, $code);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getStatusCode()
+ {
+ return $this->status_code;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getHeaders()
+ {
+ return $this->headers;
+ }
+}
diff --git a/phpBB/phpbb/exception/runtime_exception.php b/phpBB/phpbb/exception/runtime_exception.php
new file mode 100644
index 0000000000..6568bbf86f
--- /dev/null
+++ b/phpBB/phpbb/exception/runtime_exception.php
@@ -0,0 +1,52 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\exception;
+
+/**
+ * Class runtime_exception
+ *
+ * Define an exception which support a language var as message.
+ */
+class runtime_exception extends \RuntimeException implements exception_interface
+{
+ /**
+ * Parameters to use with the language var.
+ *
+ * @var array
+ */
+ private $parameters;
+
+ /**
+ * Constructor
+ *
+ * @param string $message The Exception message to throw (must be a language variable).
+ * @param array $parameters The parameters to use with the language var.
+ * @param \Exception $previous The previous runtime_exception used for the runtime_exception chaining.
+ * @param integer $code The Exception code.
+ */
+ public function __construct($message = "", array $parameters = array(), \Exception $previous = null, $code = 0)
+ {
+ $this->parameters = $parameters;
+
+ parent::__construct($message, $code, $previous);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_parameters()
+ {
+ return $this->parameters;
+ }
+}
diff --git a/phpBB/phpbb/extension/metadata_manager.php b/phpBB/phpbb/extension/metadata_manager.php
index edca8ee1af..a64d88fe39 100644
--- a/phpBB/phpbb/extension/metadata_manager.php
+++ b/phpBB/phpbb/extension/metadata_manager.php
@@ -177,6 +177,7 @@ class metadata_manager
throw new \phpbb\extension\exception($this->user->lang('FILE_JSON_DECODE_ERR', $this->metadata_file));
}
+ array_walk_recursive($metadata, array($this, 'sanitize_json'));
$this->metadata = $metadata;
return true;
@@ -184,6 +185,17 @@ class metadata_manager
}
/**
+ * Sanitize input from JSON array using htmlspecialchars()
+ *
+ * @param mixed $value Value of array row
+ * @param string $key Key of array row
+ */
+ public function sanitize_json(&$value, $key)
+ {
+ $value = htmlspecialchars($value);
+ }
+
+ /**
* This array handles the cleaning of the array
*
* @return array Contains the cleaned metadata array
@@ -337,30 +349,30 @@ class metadata_manager
public function output_template_data()
{
$this->template->assign_vars(array(
- 'META_NAME' => htmlspecialchars($this->metadata['name']),
- 'META_TYPE' => htmlspecialchars($this->metadata['type']),
- 'META_DESCRIPTION' => (isset($this->metadata['description'])) ? htmlspecialchars($this->metadata['description']) : '',
+ 'META_NAME' => $this->metadata['name'],
+ 'META_TYPE' => $this->metadata['type'],
+ 'META_DESCRIPTION' => (isset($this->metadata['description'])) ? $this->metadata['description'] : '',
'META_HOMEPAGE' => (isset($this->metadata['homepage'])) ? $this->metadata['homepage'] : '',
- 'META_VERSION' => (isset($this->metadata['version'])) ? htmlspecialchars($this->metadata['version']) : '',
- 'META_TIME' => (isset($this->metadata['time'])) ? htmlspecialchars($this->metadata['time']) : '',
- 'META_LICENSE' => htmlspecialchars($this->metadata['license']),
+ 'META_VERSION' => (isset($this->metadata['version'])) ? $this->metadata['version'] : '',
+ 'META_TIME' => (isset($this->metadata['time'])) ? $this->metadata['time'] : '',
+ 'META_LICENSE' => $this->metadata['license'],
- 'META_REQUIRE_PHP' => (isset($this->metadata['require']['php'])) ? htmlspecialchars($this->metadata['require']['php']) : '',
+ 'META_REQUIRE_PHP' => (isset($this->metadata['require']['php'])) ? $this->metadata['require']['php'] : '',
'META_REQUIRE_PHP_FAIL' => !$this->validate_require_php(),
- 'META_REQUIRE_PHPBB' => (isset($this->metadata['extra']['soft-require']['phpbb/phpbb'])) ? htmlspecialchars($this->metadata['extra']['soft-require']['phpbb/phpbb']) : '',
+ 'META_REQUIRE_PHPBB' => (isset($this->metadata['extra']['soft-require']['phpbb/phpbb'])) ? $this->metadata['extra']['soft-require']['phpbb/phpbb'] : '',
'META_REQUIRE_PHPBB_FAIL' => !$this->validate_require_phpbb(),
- 'META_DISPLAY_NAME' => (isset($this->metadata['extra']['display-name'])) ? htmlspecialchars($this->metadata['extra']['display-name']) : '',
+ 'META_DISPLAY_NAME' => (isset($this->metadata['extra']['display-name'])) ? $this->metadata['extra']['display-name'] : '',
));
foreach ($this->metadata['authors'] as $author)
{
$this->template->assign_block_vars('meta_authors', array(
- 'AUTHOR_NAME' => htmlspecialchars($author['name']),
+ 'AUTHOR_NAME' => $author['name'],
'AUTHOR_EMAIL' => (isset($author['email'])) ? $author['email'] : '',
'AUTHOR_HOMEPAGE' => (isset($author['homepage'])) ? $author['homepage'] : '',
- 'AUTHOR_ROLE' => (isset($author['role'])) ? htmlspecialchars($author['role']) : '',
+ 'AUTHOR_ROLE' => (isset($author['role'])) ? $author['role'] : '',
));
}
}
diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php
index 2af8b50b54..0c5205530b 100644
--- a/phpBB/phpbb/log/log.php
+++ b/phpBB/phpbb/log/log.php
@@ -708,6 +708,50 @@ class log implements \phpbb\log\log_interface
}
}
+ /**
+ * Allow modifying or execute extra final filter on log entries
+ *
+ * @event core.get_logs_after
+ * @var array log Array with all our log entries
+ * @var array topic_id_list Array of topic ids, for which we
+ * get the permission data
+ * @var array reportee_id_list Array of additional user IDs we
+ * get the username strings for
+ * @var string mode Mode of the entries we display
+ * @var bool count_logs Do we count all matching entries?
+ * @var int limit Limit the number of entries
+ * @var int offset Offset when fetching the entries
+ * @var mixed forum_id Limit entries to the forum_id,
+ * can also be an array of forum_ids
+ * @var int topic_id Limit entries to the topic_id
+ * @var int user_id Limit entries to the user_id
+ * @var int log_time Limit maximum age of log entries
+ * @var string sort_by SQL order option
+ * @var string keywords Will only return entries that have the
+ * keywords in log_operation or log_data
+ * @var string profile_url URL to the users profile
+ * @var int log_type The type of logs it was filtered
+ * @since 3.1.3-RC1
+ */
+ $vars = array(
+ 'log',
+ 'topic_id_list',
+ 'reportee_id_list',
+ 'mode',
+ 'count_logs',
+ 'limit',
+ 'offset',
+ 'forum_id',
+ 'topic_id',
+ 'user_id',
+ 'log_time',
+ 'sort_by',
+ 'keywords',
+ 'profile_url',
+ 'log_type',
+ );
+ extract($this->dispatcher->trigger_event('core.get_logs_after', compact($vars)));
+
return $log;
}
diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php
index dd611e1dd1..aa52eb61d0 100644
--- a/phpBB/phpbb/notification/manager.php
+++ b/phpBB/phpbb/notification/manager.php
@@ -38,6 +38,9 @@ class manager
/** @var \phpbb\config\config */
protected $config;
+ /** @var \phpbb\event\dispatcher */
+ protected $phpbb_dispatcher;
+
/** @var \phpbb\db\driver\driver_interface */
protected $db;
@@ -70,6 +73,7 @@ class manager
* @param ContainerInterface $phpbb_container
* @param \phpbb\user_loader $user_loader
* @param \phpbb\config\config $config
+ * @param \phpbb\event\dispatcher $phpbb_dispatcher
* @param \phpbb\db\driver\driver_interface $db
* @param \phpbb\cache\service $cache
* @param \phpbb\user $user
@@ -81,7 +85,7 @@ class manager
*
* @return \phpbb\notification\manager
*/
- public function __construct($notification_types, $notification_methods, ContainerInterface $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table)
+ public function __construct($notification_types, $notification_methods, ContainerInterface $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\config\config $config, \phpbb\event\dispatcher $phpbb_dispatcher, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table)
{
$this->notification_types = $notification_types;
$this->notification_methods = $notification_methods;
@@ -89,6 +93,7 @@ class manager
$this->user_loader = $user_loader;
$this->config = $config;
+ $this->phpbb_dispatcher = $phpbb_dispatcher;
$this->db = $db;
$this->cache = $cache;
$this->user = $user;
@@ -350,6 +355,26 @@ class manager
// find out which users want to receive this type of notification
$notify_users = $this->get_item_type_class($notification_type_name)->find_users_for_notification($data, $options);
+ /**
+ * Allow filtering the notify_users array for a notification that is about to be sent.
+ * Here, $notify_users is already filtered by f_read and the ignored list included in the options variable
+ *
+ * @event core.notification_manager_add_notifications
+ * @var string notification_type_name The forum id from where the topic belongs
+ * @var array data Data specific for the notification_type_name used will be inserted
+ * @var array notify_users The array of userid that are going to be notified for this notification. Set to array() to cancel.
+ * @var array options The options that were used when this method was called (read only)
+ *
+ * @since 3.1.3-RC1
+ */
+ $vars = array(
+ 'notification_type_name',
+ 'data',
+ 'notify_users',
+ 'options',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.notification_manager_add_notifications', compact($vars)));
+
$this->add_notifications_for_users($notification_type_name, $data, $notify_users);
return $notify_users;
diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php
index 4a446a5d9d..5400c1c5a6 100644
--- a/phpBB/phpbb/path_helper.php
+++ b/phpBB/phpbb/path_helper.php
@@ -282,10 +282,16 @@ class path_helper
$referer_dir = dirname($referer_dir);
}
- while (strpos($absolute_board_url, $referer_dir) !== 0)
+ while (($dir_position = strpos($absolute_board_url, $referer_dir)) !== 0)
{
$fixed_root_path .= '../';
$referer_dir = dirname($referer_dir);
+
+ // Just return phpbb_root_path if we reach the top directory
+ if ($referer_dir === '.')
+ {
+ return $this->phpbb_root_path;
+ }
}
$fixed_root_path .= substr($absolute_board_url, strlen($referer_dir) + 1);
@@ -449,4 +455,38 @@ class path_helper
return $url_parts['base'] . (($params) ? '?' . $this->glue_url_params($params) : '');
}
+
+ /**
+ * Get a valid page
+ *
+ * @param string $page The page to verify
+ * @param bool $mod_rewrite Whether mod_rewrite is enabled, default: false
+ *
+ * @return string A valid page based on given page and mod_rewrite
+ */
+ public function get_valid_page($page, $mod_rewrite = false)
+ {
+ // We need to be cautious here.
+ // On some situations, the redirect path is an absolute URL, sometimes a relative path
+ // For a relative path, let's prefix it with $phpbb_root_path to point to the correct location,
+ // else we use the URL directly.
+ $url_parts = parse_url($page);
+
+ // URL
+ if ($url_parts === false || empty($url_parts['scheme']) || empty($url_parts['host']))
+ {
+ // Remove 'app.php/' from the page, when rewrite is enabled.
+ // Treat app.php as a reserved file name and remove on mod rewrite
+ // even if it might not be in the phpBB root.
+ if ($mod_rewrite && ($app_position = strpos($page, 'app.' . $this->php_ext . '/')) !== false)
+ {
+ $page = substr($page, 0, $app_position) . substr($page, $app_position + strlen('app.' . $this->php_ext . '/'));
+ }
+
+ // Remove preceding slashes from page name and prepend root path
+ $page = $this->get_phpbb_root_path() . ltrim($page, '/\\');
+ }
+
+ return $page;
+ }
}
diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php
index 75934e3be7..f6f3f17a6c 100644
--- a/phpBB/phpbb/profilefields/type/type_bool.php
+++ b/phpBB/phpbb/profilefields/type/type_bool.php
@@ -173,7 +173,7 @@ class type_bool extends type_base
}
else
{
- return $this->lang_helper->is_set($field_id, $lang_id, $field_value + 1);
+ return $this->lang_helper->is_set($field_id, $lang_id, $field_value + 1) ? $this->lang_helper->get($field_id, $lang_id, $field_value + 1) : null;
}
}
@@ -367,29 +367,29 @@ class type_bool extends type_base
*/
public function prepare_hidden_fields($step, $key, $action, &$field_data)
{
- if ($key == 'l_lang_options' && $this->request->is_set('l_lang_options'))
+ if ($key == 'field_default_value')
{
- return $this->request->variable($key, array(array('')), true);
- }
- else if ($key == 'field_default_value')
- {
- return $this->request->variable($key, $field_data[$key]);
- }
- else
- {
- if (!$this->request->is_set($key))
- {
- return false;
- }
- else if ($key == 'field_ident' && isset($field_data[$key]))
- {
- return $field_data[$key];
- }
- else
+ $field_length = $this->request->variable('field_length', 0);
+
+ // Do a simple is set check if using checkbox.
+ if ($field_length == 2)
{
- return ($key == 'lang_options') ? $this->request->variable($key, array(''), true) : $this->request->variable($key, '', true);
+ return $this->request->is_set($key);
}
+ return $this->request->variable($key, $field_data[$key], true);
+ }
+
+ $default_lang_options = array(
+ 'l_lang_options' => array(0 => array('')),
+ 'lang_options' => array(0 => ''),
+ );
+
+ if (isset($default_lang_options[$key]) && $this->request->is_set($key))
+ {
+ return $this->request->variable($key, $default_lang_options[$key], true);
}
+
+ return parent::prepare_hidden_fields($step, $key, $action, $field_data);
}
/**
diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php
index ff33a7b49c..f5e1992044 100644
--- a/phpBB/phpbb/profilefields/type/type_string_common.php
+++ b/phpBB/phpbb/profilefields/type/type_string_common.php
@@ -18,11 +18,11 @@ abstract class type_string_common extends type_base
protected $validation_options = array(
'CHARS_ANY' => '.*',
'NUMBERS_ONLY' => '[0-9]+',
- 'ALPHA_ONLY' => '[\w]+',
- 'ALPHA_UNDERSCORE' => '[\w_]+',
- 'ALPHA_DOTS' => '[\w.]+',
- 'ALPHA_SPACERS' => '[\w\x20_+\-\[\]]+',
- 'ALPHA_PUNCTUATION' => '[a-zA-Z][\w\.,\-_]+',
+ 'ALPHA_ONLY' => '[a-zA-Z0-9]+',
+ 'ALPHA_UNDERSCORE' => '[\w]+',
+ 'ALPHA_DOTS' => '[a-zA-Z0-9.]+',
+ 'ALPHA_SPACERS' => '[\w\x20+\-\[\]]+',
+ 'ALPHA_PUNCTUATION' => '[a-zA-Z][\w\.,\-]+',
'LETTER_NUM_ONLY' => '[\p{Lu}\p{Ll}0-9]+',
'LETTER_NUM_UNDERSCORE' => '[\p{Lu}\p{Ll}0-9_]+',
'LETTER_NUM_DOTS' => '[\p{Lu}\p{Ll}0-9.]+',
diff --git a/phpBB/phpbb/profilefields/type/type_url.php b/phpBB/phpbb/profilefields/type/type_url.php
index bc8ac869d0..fe0bffd582 100644
--- a/phpBB/phpbb/profilefields/type/type_url.php
+++ b/phpBB/phpbb/profilefields/type/type_url.php
@@ -64,7 +64,7 @@ class type_url extends type_string
return false;
}
- if (!preg_match('#^' . get_preg_expression('url') . '$#i', $field_value))
+ if (!preg_match('#^' . get_preg_expression('url') . '$#iu', $field_value))
{
return $this->user->lang('FIELD_INVALID_URL', $this->get_field_name($field_data['lang_name']));
}
diff --git a/phpBB/phpbb/request/request.php b/phpBB/phpbb/request/request.php
index f0f2f7e2a2..56ce3999ed 100644
--- a/phpBB/phpbb/request/request.php
+++ b/phpBB/phpbb/request/request.php
@@ -275,7 +275,7 @@ class request implements \phpbb\request\request_interface
*/
public function file($form_name)
{
- return $this->variable($form_name, array('name' => 'none'), false, \phpbb\request\request_interface::FILES);
+ return $this->variable($form_name, array('name' => 'none'), true, \phpbb\request\request_interface::FILES);
}
/**
diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php
index ea239c0b36..69025fc08f 100644
--- a/phpBB/phpbb/search/fulltext_native.php
+++ b/phpBB/phpbb/search/fulltext_native.php
@@ -437,7 +437,7 @@ class fulltext_native extends \phpbb\search\base
// throw an error if we shall not ignore unexistant words
else if (!$ignore_no_id && sizeof($non_common_words))
{
- trigger_error(sprintf($user->lang['WORDS_IN_NO_POST'], implode($user->lang['COMMA_SEPARATOR'], $non_common_words)));
+ trigger_error(sprintf($this->user->lang['WORDS_IN_NO_POST'], implode($this->user->lang['COMMA_SEPARATOR'], $non_common_words)));
}
unset($non_common_words);
}
diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php
index eb53ca6d40..2765d05b94 100644
--- a/phpBB/phpbb/search/fulltext_sphinx.php
+++ b/phpBB/phpbb/search/fulltext_sphinx.php
@@ -85,7 +85,7 @@ class fulltext_sphinx
/**
* Database Tools object
- * @var \phpbb\db\tools
+ * @var \phpbb\db\tools\tools_interface
*/
protected $db_tools;
@@ -135,8 +135,8 @@ class fulltext_sphinx
$this->db = $db;
$this->auth = $auth;
- // Initialize \phpbb\db\tools object
- $this->db_tools = new \phpbb\db\tools($this->db);
+ // Initialize \phpbb\db\tools\tools object
+ $this->db_tools = new \phpbb\db\tools\tools($this->db);
if(!$this->config['fulltext_sphinx_id'])
{
diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php
index dc90d942c3..5b9fb6d835 100644
--- a/phpBB/phpbb/session.php
+++ b/phpBB/phpbb/session.php
@@ -409,6 +409,7 @@ class session
$session_expired = false;
// Check whether the session is still valid if we have one
+ /* @var $provider_collection \phpbb\auth\provider_collection */
$provider_collection = $phpbb_container->get('auth.provider_collection');
$provider = $provider_collection->get_provider();
@@ -578,6 +579,7 @@ class session
}
}
+ /* @var $provider_collection \phpbb\auth\provider_collection */
$provider_collection = $phpbb_container->get('auth.provider_collection');
$provider = $provider_collection->get_provider();
$this->data = $provider->autologin();
@@ -910,6 +912,7 @@ class session
$db->sql_query($sql);
// Allow connecting logout with external auth method logout
+ /* @var $provider_collection \phpbb\auth\provider_collection */
$provider_collection = $phpbb_container->get('auth.provider_collection');
$provider = $provider_collection->get_provider();
$provider->logout($this->data, $new_session);
@@ -1036,6 +1039,7 @@ class session
}
// only called from CRON; should be a safe workaround until the infrastructure gets going
+ /* @var $captcha_factory \phpbb\captcha\factory */
$captcha_factory = $phpbb_container->get('captcha.factory');
$captcha_factory->garbage_collect($config['captcha_plugin']);
@@ -1063,7 +1067,7 @@ class session
$name_data = rawurlencode($config['cookie_name'] . '_' . $name) . '=' . rawurlencode($cookiedata);
$expire = gmdate('D, d-M-Y H:i:s \\G\\M\\T', $cookietime);
- $domain = (!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain'];
+ $domain = (!$config['cookie_domain'] || $config['cookie_domain'] == '127.0.0.1' || strpos($config['cookie_domain'], '.') === false) ? '' : '; domain=' . $config['cookie_domain'];
header('Set-Cookie: ' . $name_data . (($cookietime) ? '; expires=' . $expire : '') . '; path=' . $config['cookie_path'] . $domain . ((!$config['cookie_secure']) ? '' : '; secure') . ';' . (($httponly) ? ' HttpOnly' : ''), false);
}
@@ -1082,7 +1086,7 @@ class session
*/
function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false)
{
- global $config, $db;
+ global $config, $db, $phpbb_dispatcher;
if (defined('IN_CHECK_BAN') || defined('SKIP_CHECK_BAN'))
{
@@ -1196,6 +1200,20 @@ class session
}
$db->sql_freeresult($result);
+ /**
+ * Event to set custom ban type
+ *
+ * @event core.session_set_custom_ban
+ * @var bool return If $return is false this routine does not return on finding a banned user, it outputs a relevant message and stops execution
+ * @var bool banned Check if user already banned
+ * @var array|false ban_row Ban data
+ * @var string ban_triggered_by Method that caused ban, can be your custom method
+ * @since 3.1.3-RC1
+ */
+ $ban_row = isset($ban_row) ? $ban_row : false;
+ $vars = array('return', 'banned', 'ban_row', 'ban_triggered_by');
+ extract($phpbb_dispatcher->trigger_event('core.session_set_custom_ban', compact($vars)));
+
if ($banned && !$return)
{
global $template, $phpbb_root_path, $phpEx;
diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php
index 4962d14aef..605d37e954 100644
--- a/phpBB/phpbb/template/twig/twig.php
+++ b/phpBB/phpbb/template/twig/twig.php
@@ -261,19 +261,19 @@ class twig extends \phpbb\template\base
$ext_style_theme_path = $ext_style_path . 'theme/';
}
- $ok = false;
+ $is_valid_dir = false;
if (is_dir($ext_style_template_path))
{
- $ok = true;
+ $is_valid_dir = true;
$paths[] = $ext_style_template_path;
}
if (is_dir($ext_style_theme_path))
{
- $ok = true;
+ $is_valid_dir = true;
$paths[] = $ext_style_theme_path;
}
- if ($ok)
+ if ($is_valid_dir)
{
// Add the base style directory as a safe directory
$this->twig->getLoader()->addSafeDirectory($ext_style_path);
diff --git a/phpBB/phpbb/user_loader.php b/phpBB/phpbb/user_loader.php
index 24e663b150..0b192e4452 100644
--- a/phpBB/phpbb/user_loader.php
+++ b/phpBB/phpbb/user_loader.php
@@ -175,7 +175,7 @@ class user_loader
/**
* Get avatar
*
- * @param int $user_id User ID of the user you want to retreive the avatar for
+ * @param int $user_id User ID of the user you want to retrieve the avatar for
* @param bool $query Should we query the database if this user has not yet been loaded?
* Typically this should be left as false and you should make sure
* you load users ahead of time with load_users()
@@ -188,12 +188,14 @@ class user_loader
return '';
}
- if (!function_exists('get_user_avatar'))
- {
- include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext);
- }
+ $row = array(
+ 'avatar' => $user['user_avatar'],
+ 'avatar_type' => $user['user_avatar_type'],
+ 'avatar_width' => $user['user_avatar_width'],
+ 'avatar_height' => $user['user_avatar_height'],
+ );
- return get_user_avatar($user['user_avatar'], $user['user_avatar_type'], $user['user_avatar_width'], $user['user_avatar_height']);
+ return phpbb_get_avatar($row, 'USER_AVATAR');
}
/**
diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php
index e34bd0ba60..dc62f06fb2 100644
--- a/phpBB/phpbb/version_helper.php
+++ b/phpBB/phpbb/version_helper.php
@@ -259,7 +259,7 @@ class version_helper
}
catch (\RuntimeException $exception)
{
- throw new \RuntimeException(call_user_func_array(array($this->user, 'lang'), $exception->getMessage()));
+ throw new \RuntimeException($this->user->lang($exception->getMessage()));
}
$error_string = $this->file_downloader->get_error_string();
@@ -270,6 +270,16 @@ class version_helper
$info = json_decode($info, true);
+ // Sanitize any data we retrieve from a server
+ if (!empty($info))
+ {
+ $json_sanitizer = function (&$value, $key) {
+ $type_cast_helper = new \phpbb\request\type_cast_helper();
+ $type_cast_helper->set_var($value, $value, gettype($value), true);
+ };
+ array_walk_recursive($info, $json_sanitizer);
+ }
+
if (empty($info['stable']) && empty($info['unstable']))
{
$this->user->add_lang('acp/common');
@@ -277,15 +287,6 @@ class version_helper
throw new \RuntimeException($this->user->lang('VERSIONCHECK_FAIL'));
}
- // Replace & with &amp; on announcement links
- foreach ($info as $stability => $branches)
- {
- foreach ($branches as $branch => $branch_data)
- {
- $info[$stability][$branch]['announcement'] = (!empty($branch_data['announcement'])) ? str_replace('&', '&amp;', $branch_data['announcement']) : '';
- }
- }
-
$info['stable'] = (empty($info['stable'])) ? array() : $info['stable'];
$info['unstable'] = (empty($info['unstable'])) ? $info['stable'] : $info['unstable'];