mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into ticket/10714
* 'develop' of https://github.com/phpbb/phpbb3: (158 commits) [ticket/11015] Move comment in the right place. [ticket/11015] Correctly transform 'mysqli' etc. in phpbb_convert_30_dbms_to_31 [ticket/11015] Fix 3.0 to 3.1 dbms conversion for mysqli. [ticket/11015] Change permission adding in database updater to new style. [ticket/11015] Change more docblocks to phpbb_db_driver. [ticket/11015] Installer still needs 3.0-style dbms name. [ticket/11262] Add .lock in cache directory to .gitignore [ticket/11015] Include functions.php because it is not always included. [ticket/11265] Add assertions for board installation success. [ticket/11263] Fix PHP Notice: Undefined variable: extension_manager [ticket/11015] Convert database drivers to new spelling in post setup sync. [ticket/11015] Convert connect test to the new syntax. [ticket/11015] Restore whitespace to avoid conflict when merging develop. [ticket/10975] Add a test for viewing a profile. [ticket/10975] Test restricting by first character. [ticket/10975] Avoid rewriting global config twice. [ticket/10975] Test memberlist, not user creation. [ticket/10975] Some quick tests to check the memberlist behaviour [ticket/11162] Reformat. [ticket/10491] Make recreate_database static. ...
This commit is contained in:
commit
be8140d79c
105 changed files with 2030 additions and 405 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,7 +2,7 @@
|
|||
/phpunit.xml
|
||||
/phpBB/cache/*.html
|
||||
/phpBB/cache/*.php
|
||||
/phpBB/cache/queue.php.lock
|
||||
/phpBB/cache/*.lock
|
||||
/phpBB/composer.phar
|
||||
/phpBB/config.php
|
||||
/phpBB/config_dev.php
|
||||
|
|
|
@ -52,7 +52,7 @@ $mode = request_var('mode', '');
|
|||
|
||||
// Set custom style for admin area
|
||||
$phpbb_style->set_ext_dir_prefix('adm/');
|
||||
$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', '');
|
||||
$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), '');
|
||||
$template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets');
|
||||
$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ $user->setup();
|
|||
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
|
||||
|
||||
// Set custom template for admin area
|
||||
$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', '');
|
||||
$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), '');
|
||||
|
||||
$template->set_filenames(array(
|
||||
'body' => 'colour_swatch.html')
|
||||
|
|
|
@ -71,7 +71,6 @@ require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
|
|||
require($phpbb_root_path . 'includes/functions_container.' . $phpEx);
|
||||
|
||||
require($phpbb_root_path . 'includes/constants.' . $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
|
||||
|
|
|
@ -6,6 +6,8 @@ services:
|
|||
- %core.php_ext%
|
||||
- @config
|
||||
- @dbal.conn
|
||||
calls:
|
||||
- [set_name, [cron.task.core.prune_all_forums]]
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
|
@ -16,6 +18,8 @@ services:
|
|||
- %core.php_ext%
|
||||
- @config
|
||||
- @dbal.conn
|
||||
calls:
|
||||
- [set_name, [cron.task.core.prune_forum]]
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
|
@ -25,6 +29,8 @@ services:
|
|||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @config
|
||||
calls:
|
||||
- [set_name, [cron.task.core.queue]]
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
|
@ -33,6 +39,8 @@ services:
|
|||
arguments:
|
||||
- @config
|
||||
- @cache.driver
|
||||
calls:
|
||||
- [set_name, [cron.task.core.tidy_cache]]
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
|
@ -42,6 +50,8 @@ services:
|
|||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @config
|
||||
calls:
|
||||
- [set_name, [cron.task.core.tidy_database]]
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
|
@ -54,6 +64,8 @@ services:
|
|||
- @config
|
||||
- @dbal.conn
|
||||
- @user
|
||||
calls:
|
||||
- [set_name, [cron.task.core.tidy_search]]
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
|
@ -62,6 +74,8 @@ services:
|
|||
arguments:
|
||||
- @config
|
||||
- @user
|
||||
calls:
|
||||
- [set_name, [cron.task.core.tidy_sessions]]
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
||||
|
@ -71,5 +85,7 @@ services:
|
|||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @config
|
||||
calls:
|
||||
- [set_name, [cron.task.core.tidy_warnings]]
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
|
|
|
@ -59,15 +59,6 @@ services:
|
|||
- @service_container
|
||||
- @ext.finder
|
||||
|
||||
controller.route_collection:
|
||||
class: phpbb_controller_route_collection
|
||||
arguments:
|
||||
- @ext.finder
|
||||
- @controller.provider
|
||||
|
||||
controller.provider:
|
||||
class: phpbb_controller_provider
|
||||
|
||||
cron.task_collection:
|
||||
class: phpbb_di_service_collection
|
||||
arguments:
|
||||
|
@ -200,6 +191,7 @@ services:
|
|||
- @user
|
||||
- @style.resource_locator
|
||||
- @template_context
|
||||
- @ext.manager
|
||||
|
||||
template_context:
|
||||
class: phpbb_template_context
|
||||
|
|
|
@ -43,7 +43,6 @@ if (isset($_GET['avatar']))
|
|||
|
||||
require($phpbb_root_path . 'includes/class_loader.' . $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_container.' . $phpEx);
|
||||
|
|
|
@ -16,10 +16,10 @@ class acp_extensions_info
|
|||
{
|
||||
return array(
|
||||
'filename' => 'acp_extensions',
|
||||
'title' => 'ACP_EXTENSIONS',
|
||||
'title' => 'ACP_EXTENSIONS_MANAGEMENT',
|
||||
'version' => '1.0.0',
|
||||
'modes' => array(
|
||||
'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_GENERAL_TASKS')),
|
||||
'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_EXTENSIONS_MANAGEMENT')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class acp_language_info
|
|||
'title' => 'ACP_LANGUAGE',
|
||||
'version' => '1.0.0',
|
||||
'modes' => array(
|
||||
'lang_packs' => array('title' => 'ACP_LANGUAGE_PACKS', 'auth' => 'acl_a_language', 'cat' => array('ACP_GENERAL_TASKS')),
|
||||
'lang_packs' => array('title' => 'ACP_LANGUAGE_PACKS', 'auth' => 'acl_a_language', 'cat' => array('ACP_LANGUAGE')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ class bbcode
|
|||
|
||||
$style_resource_locator = new phpbb_style_resource_locator();
|
||||
$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, $style_resource_locator, new phpbb_template_context());
|
||||
$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, new phpbb_template_context(), $phpbb_extension_manager);
|
||||
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $template);
|
||||
$style->set_style();
|
||||
$template->set_filenames(array('bbcode.html' => 'bbcode.html'));
|
||||
|
|
|
@ -29,7 +29,7 @@ class phpbb_config_db extends phpbb_config
|
|||
|
||||
/**
|
||||
* Database connection
|
||||
* @var dbal
|
||||
* @var phpbb_db_driver
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
|
@ -42,11 +42,11 @@ class phpbb_config_db extends phpbb_config
|
|||
/**
|
||||
* Creates a configuration container with a default set of values
|
||||
*
|
||||
* @param dbal $db Database connection
|
||||
* @param phpbb_db_driver $db Database connection
|
||||
* @param phpbb_cache_driver_interface $cache Cache instance
|
||||
* @param string $table Configuration table name
|
||||
*/
|
||||
public function __construct(dbal $db, phpbb_cache_driver_interface $cache, $table)
|
||||
public function __construct(phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $table)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->cache = $cache;
|
||||
|
|
|
@ -37,9 +37,9 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base
|
|||
* @param string $phpbb_root_path The root path
|
||||
* @param string $php_ext The PHP extension
|
||||
* @param phpbb_config $config The config
|
||||
* @param dbal $db The db connection
|
||||
* @param phpbb_db_driver $db The db connection
|
||||
*/
|
||||
public function __construct($phpbb_root_path, $php_ext, phpbb_config $config, dbal $db)
|
||||
public function __construct($phpbb_root_path, $php_ext, phpbb_config $config, phpbb_db_driver $db)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
|
|
|
@ -47,9 +47,9 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p
|
|||
* @param string $phpbb_root_path The root path
|
||||
* @param string $php_ext The PHP extension
|
||||
* @param phpbb_config $config The config
|
||||
* @param dbal $db The db connection
|
||||
* @param phpbb_db_driver $db The db connection
|
||||
*/
|
||||
public function __construct($phpbb_root_path, $php_ext, phpbb_config $config, dbal $db)
|
||||
public function __construct($phpbb_root_path, $php_ext, phpbb_config $config, phpbb_db_driver $db)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
|
|
|
@ -38,10 +38,10 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base
|
|||
* @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_db_driver $db The db connection
|
||||
* @param phpbb_user $user The user
|
||||
*/
|
||||
public function __construct($phpbb_root_path, $php_ext, phpbb_auth $auth, phpbb_config $config, dbal $db, phpbb_user $user)
|
||||
public function __construct($phpbb_root_path, $php_ext, phpbb_auth $auth, phpbb_config $config, phpbb_db_driver $db, phpbb_user $user)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
|
|
|
@ -300,7 +300,7 @@ class phpbb_db_tools
|
|||
/**
|
||||
* Constructor. Set DB Object and set {@link $return_statements return_statements}.
|
||||
*
|
||||
* @param phpbb_dbal $db DBAL object
|
||||
* @param phpbb_db_driver $db Database connection
|
||||
* @param bool $return_statements True if only statements should be returned and no SQL being executed
|
||||
*/
|
||||
function phpbb_db_tools(&$db, $return_statements = false)
|
||||
|
|
|
@ -19,7 +19,7 @@ if (!defined('IN_PHPBB'))
|
|||
* Database Abstraction Layer
|
||||
* @package dbal
|
||||
*/
|
||||
class dbal
|
||||
class phpbb_db_driver
|
||||
{
|
||||
var $db_connect_id;
|
||||
var $query_result;
|
||||
|
@ -72,17 +72,17 @@ class dbal
|
|||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function dbal()
|
||||
function __construct()
|
||||
{
|
||||
$this->num_queries = array(
|
||||
'cached' => 0,
|
||||
'normal' => 0,
|
||||
'total' => 0,
|
||||
'cached' => 0,
|
||||
'normal' => 0,
|
||||
'total' => 0,
|
||||
);
|
||||
|
||||
// Fill default sql layer based on the class being called.
|
||||
// This can be changed by the specified layer itself later if needed.
|
||||
$this->sql_layer = substr(get_class($this), 5);
|
||||
$this->sql_layer = substr(get_class($this), strlen('phpbb_db_driver_'));
|
||||
|
||||
// Do not change this please! This variable is used to easy the use of it - and is hardcoded.
|
||||
$this->any_char = chr(0) . '%';
|
||||
|
@ -1042,8 +1042,3 @@ class dbal
|
|||
return $rows_total;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This variable holds the class name to use later
|
||||
*/
|
||||
$sql_db = (!empty($dbms)) ? 'dbal_' . basename($dbms) : 'dbal';
|
|
@ -15,14 +15,12 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
||||
|
||||
/**
|
||||
* Firebird/Interbase Database Abstraction Layer
|
||||
* Minimum Requirement is Firebird 2.1
|
||||
* @package dbal
|
||||
*/
|
||||
class dbal_firebird extends dbal
|
||||
class phpbb_db_driver_firebird extends phpbb_db_driver
|
||||
{
|
||||
var $last_query_text = '';
|
||||
var $service_handle = false;
|
|
@ -15,20 +15,26 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
||||
|
||||
/**
|
||||
* MSSQL Database Abstraction Layer
|
||||
* Minimum Requirement is MSSQL 2000+
|
||||
* @package dbal
|
||||
*/
|
||||
class dbal_mssql extends dbal
|
||||
class phpbb_db_driver_mssql extends phpbb_db_driver
|
||||
{
|
||||
var $connect_error = '';
|
||||
|
||||
/**
|
||||
* Connect to server
|
||||
*/
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
|
||||
{
|
||||
if (!function_exists('mssql_connect'))
|
||||
{
|
||||
$this->connect_error = 'mssql_connect function does not exist, is mssql extension installed?';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
|
||||
$this->persistency = $persistency;
|
||||
$this->user = $sqluser;
|
||||
$this->dbname = $database;
|
||||
|
@ -355,34 +361,44 @@ class dbal_mssql extends dbal
|
|||
*/
|
||||
function _sql_error()
|
||||
{
|
||||
$error = array(
|
||||
'message' => @mssql_get_last_message(),
|
||||
'code' => ''
|
||||
);
|
||||
|
||||
// Get error code number
|
||||
$result_id = @mssql_query('SELECT @@ERROR as code', $this->db_connect_id);
|
||||
if ($result_id)
|
||||
if (function_exists('mssql_get_last_message'))
|
||||
{
|
||||
$row = @mssql_fetch_assoc($result_id);
|
||||
$error['code'] = $row['code'];
|
||||
@mssql_free_result($result_id);
|
||||
}
|
||||
$error = array(
|
||||
'message' => @mssql_get_last_message(),
|
||||
'code' => '',
|
||||
);
|
||||
|
||||
// Get full error message if possible
|
||||
$sql = 'SELECT CAST(description as varchar(255)) as message
|
||||
FROM master.dbo.sysmessages
|
||||
WHERE error = ' . $error['code'];
|
||||
$result_id = @mssql_query($sql);
|
||||
|
||||
if ($result_id)
|
||||
{
|
||||
$row = @mssql_fetch_assoc($result_id);
|
||||
if (!empty($row['message']))
|
||||
// Get error code number
|
||||
$result_id = @mssql_query('SELECT @@ERROR as code', $this->db_connect_id);
|
||||
if ($result_id)
|
||||
{
|
||||
$error['message'] .= '<br />' . $row['message'];
|
||||
$row = @mssql_fetch_assoc($result_id);
|
||||
$error['code'] = $row['code'];
|
||||
@mssql_free_result($result_id);
|
||||
}
|
||||
@mssql_free_result($result_id);
|
||||
|
||||
// Get full error message if possible
|
||||
$sql = 'SELECT CAST(description as varchar(255)) as message
|
||||
FROM master.dbo.sysmessages
|
||||
WHERE error = ' . $error['code'];
|
||||
$result_id = @mssql_query($sql);
|
||||
|
||||
if ($result_id)
|
||||
{
|
||||
$row = @mssql_fetch_assoc($result_id);
|
||||
if (!empty($row['message']))
|
||||
{
|
||||
$error['message'] .= '<br />' . $row['message'];
|
||||
}
|
||||
@mssql_free_result($result_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = array(
|
||||
'message' => $this->connect_error,
|
||||
'code' => '',
|
||||
);
|
||||
}
|
||||
|
||||
return $error;
|
|
@ -15,8 +15,6 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
||||
|
||||
/**
|
||||
* Unified ODBC functions
|
||||
* Unified ODBC functions support any database having ODBC driver, for example Adabas D, IBM DB2, iODBC, Solid, Sybase SQL Anywhere...
|
||||
|
@ -28,9 +26,10 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
|||
*
|
||||
* @package dbal
|
||||
*/
|
||||
class dbal_mssql_odbc extends dbal
|
||||
class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
|
||||
{
|
||||
var $last_query_text = '';
|
||||
var $connect_error = '';
|
||||
|
||||
/**
|
||||
* Connect to server
|
||||
|
@ -67,7 +66,24 @@ class dbal_mssql_odbc extends dbal
|
|||
@ini_set('odbc.defaultlrl', $max_size);
|
||||
}
|
||||
|
||||
$this->db_connect_id = ($this->persistency) ? @odbc_pconnect($this->server, $this->user, $sqlpassword) : @odbc_connect($this->server, $this->user, $sqlpassword);
|
||||
if ($this->persistency)
|
||||
{
|
||||
if (!function_exists('odbc_pconnect'))
|
||||
{
|
||||
$this->connect_error = 'odbc_pconnect function does not exist, is odbc extension installed?';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
$this->db_connect_id = @odbc_pconnect($this->server, $this->user, $sqlpassword);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!function_exists('odbc_connect'))
|
||||
{
|
||||
$this->connect_error = 'odbc_connect function does not exist, is odbc extension installed?';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
$this->db_connect_id = @odbc_connect($this->server, $this->user, $sqlpassword);
|
||||
}
|
||||
|
||||
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
|
||||
}
|
||||
|
@ -349,10 +365,22 @@ class dbal_mssql_odbc extends dbal
|
|||
*/
|
||||
function _sql_error()
|
||||
{
|
||||
return array(
|
||||
'message' => @odbc_errormsg(),
|
||||
'code' => @odbc_error()
|
||||
);
|
||||
if (function_exists('odbc_errormsg'))
|
||||
{
|
||||
$error = array(
|
||||
'message' => @odbc_errormsg(),
|
||||
'code' => @odbc_error(),
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = array(
|
||||
'message' => $this->connect_error,
|
||||
'code' => '',
|
||||
);
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
|
@ -19,8 +19,6 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
||||
|
||||
/**
|
||||
* Prior to version 1.1 the SQL Server Native PHP driver didn't support sqlsrv_num_rows, or cursor based seeking so we recall all rows into an array
|
||||
* and maintain our own cursor index into that array.
|
||||
|
@ -193,21 +191,23 @@ class result_mssqlnative
|
|||
/**
|
||||
* @package dbal
|
||||
*/
|
||||
class dbal_mssqlnative extends dbal
|
||||
class phpbb_db_driver_mssqlnative extends phpbb_db_driver
|
||||
{
|
||||
var $m_insert_id = NULL;
|
||||
var $last_query_text = '';
|
||||
var $query_options = array();
|
||||
var $connect_error = '';
|
||||
|
||||
/**
|
||||
* Connect to server
|
||||
*/
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
|
||||
{
|
||||
# Test for driver support, to avoid suppressed fatal error
|
||||
// Test for driver support, to avoid suppressed fatal error
|
||||
if (!function_exists('sqlsrv_connect'))
|
||||
{
|
||||
trigger_error('Native MS SQL Server driver for PHP is missing or needs to be updated. Version 1.1 or later is required to install phpBB3. You can download the driver from: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx\n', E_USER_ERROR);
|
||||
$this->connect_error = 'Native MS SQL Server driver for PHP is missing or needs to be updated. Version 1.1 or later is required to install phpBB3. You can download the driver from: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
|
||||
//set up connection variables
|
||||
|
@ -521,31 +521,43 @@ class dbal_mssqlnative extends dbal
|
|||
*/
|
||||
function _sql_error()
|
||||
{
|
||||
$errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS);
|
||||
$error_message = '';
|
||||
$code = 0;
|
||||
|
||||
if ($errors != null)
|
||||
if (function_exists('sqlsrv_errors'))
|
||||
{
|
||||
foreach ($errors as $error)
|
||||
$errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS);
|
||||
$error_message = '';
|
||||
$code = 0;
|
||||
|
||||
if ($errors != null)
|
||||
{
|
||||
$error_message .= "SQLSTATE: ".$error[ 'SQLSTATE']."\n";
|
||||
$error_message .= "code: ".$error[ 'code']."\n";
|
||||
$code = $error['code'];
|
||||
$error_message .= "message: ".$error[ 'message']."\n";
|
||||
foreach ($errors as $error)
|
||||
{
|
||||
$error_message .= "SQLSTATE: " . $error[ 'SQLSTATE'] . "\n";
|
||||
$error_message .= "code: " . $error[ 'code'] . "\n";
|
||||
$code = $error['code'];
|
||||
$error_message .= "message: " . $error[ 'message'] . "\n";
|
||||
}
|
||||
$this->last_error_result = $error_message;
|
||||
$error = $this->last_error_result;
|
||||
}
|
||||
$this->last_error_result = $error_message;
|
||||
$error = $this->last_error_result;
|
||||
else
|
||||
{
|
||||
$error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
|
||||
}
|
||||
|
||||
$error = array(
|
||||
'message' => $error,
|
||||
'code' => $code,
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
|
||||
$error = array(
|
||||
'message' => $this->connect_error,
|
||||
'code' => '',
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'message' => $error,
|
||||
'code' => $code,
|
||||
);
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
|
@ -15,8 +15,6 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
||||
|
||||
/**
|
||||
* MySQL4 Database Abstraction Layer
|
||||
* Compatible with:
|
||||
|
@ -26,9 +24,10 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
|||
* MySQL 5.0+
|
||||
* @package dbal
|
||||
*/
|
||||
class dbal_mysql extends dbal
|
||||
class phpbb_db_driver_mysql extends phpbb_db_driver
|
||||
{
|
||||
var $multi_insert = true;
|
||||
var $connect_error = '';
|
||||
|
||||
/**
|
||||
* Connect to server
|
||||
|
@ -43,7 +42,24 @@ class dbal_mysql extends dbal
|
|||
|
||||
$this->sql_layer = 'mysql4';
|
||||
|
||||
$this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $sqlpassword) : @mysql_connect($this->server, $this->user, $sqlpassword, $new_link);
|
||||
if ($this->persistency)
|
||||
{
|
||||
if (!function_exists('mysql_pconnect'))
|
||||
{
|
||||
$this->connect_error = 'mysql_pconnect function does not exist, is mysql extension installed?';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
$this->db_connect_id = @mysql_pconnect($this->server, $this->user, $sqlpassword);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!function_exists('mysql_connect'))
|
||||
{
|
||||
$this->connect_error = 'mysql_connect function does not exist, is mysql extension installed?';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
$this->db_connect_id = @mysql_connect($this->server, $this->user, $sqlpassword, $new_link);
|
||||
}
|
||||
|
||||
if ($this->db_connect_id && $this->dbname != '')
|
||||
{
|
||||
|
@ -426,18 +442,29 @@ class dbal_mysql extends dbal
|
|||
*/
|
||||
function _sql_error()
|
||||
{
|
||||
if (!$this->db_connect_id)
|
||||
if ($this->db_connect_id)
|
||||
{
|
||||
return array(
|
||||
$error = array(
|
||||
'message' => @mysql_error($this->db_connect_id),
|
||||
'code' => @mysql_errno($this->db_connect_id),
|
||||
);
|
||||
}
|
||||
else if (function_exists('mysql_error'))
|
||||
{
|
||||
$error = array(
|
||||
'message' => @mysql_error(),
|
||||
'code' => @mysql_errno()
|
||||
'code' => @mysql_errno(),
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = array(
|
||||
'message' => $this->connect_error,
|
||||
'code' => '',
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'message' => @mysql_error($this->db_connect_id),
|
||||
'code' => @mysql_errno($this->db_connect_id)
|
||||
);
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
|
@ -15,23 +15,28 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
||||
|
||||
/**
|
||||
* MySQLi Database Abstraction Layer
|
||||
* mysqli-extension has to be compiled with:
|
||||
* MySQL 4.1+ or MySQL 5.0+
|
||||
* @package dbal
|
||||
*/
|
||||
class dbal_mysqli extends dbal
|
||||
class phpbb_db_driver_mysqli extends phpbb_db_driver
|
||||
{
|
||||
var $multi_insert = true;
|
||||
var $connect_error = '';
|
||||
|
||||
/**
|
||||
* Connect to server
|
||||
*/
|
||||
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false , $new_link = false)
|
||||
{
|
||||
if (!function_exists('mysqli_connect'))
|
||||
{
|
||||
$this->connect_error = 'mysqli_connect function does not exist, is mysqli extension installed?';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
|
||||
// Mysqli extension supports persistent connection since PHP 5.3.0
|
||||
$this->persistency = (version_compare(PHP_VERSION, '5.3.0', '>=')) ? $persistency : false;
|
||||
$this->user = $sqluser;
|
||||
|
@ -423,18 +428,29 @@ class dbal_mysqli extends dbal
|
|||
*/
|
||||
function _sql_error()
|
||||
{
|
||||
if (!$this->db_connect_id)
|
||||
if ($this->db_connect_id)
|
||||
{
|
||||
return array(
|
||||
$error = array(
|
||||
'message' => @mysqli_error($this->db_connect_id),
|
||||
'code' => @mysqli_errno($this->db_connect_id)
|
||||
);
|
||||
}
|
||||
else if (function_exists('mysqli_connect_error'))
|
||||
{
|
||||
$error = array(
|
||||
'message' => @mysqli_connect_error(),
|
||||
'code' => @mysqli_connect_errno()
|
||||
'code' => @mysqli_connect_errno(),
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = array(
|
||||
'message' => $this->connect_error,
|
||||
'code' => '',
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'message' => @mysqli_error($this->db_connect_id),
|
||||
'code' => @mysqli_errno($this->db_connect_id)
|
||||
);
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
|
@ -15,15 +15,14 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
||||
|
||||
/**
|
||||
* Oracle Database Abstraction Layer
|
||||
* @package dbal
|
||||
*/
|
||||
class dbal_oracle extends dbal
|
||||
class phpbb_db_driver_oracle extends phpbb_db_driver
|
||||
{
|
||||
var $last_query_text = '';
|
||||
var $connect_error = '';
|
||||
|
||||
/**
|
||||
* Connect to server
|
||||
|
@ -47,7 +46,33 @@ class dbal_oracle extends dbal
|
|||
$connect = $sqlserver . (($port) ? ':' . $port : '') . '/' . $database;
|
||||
}
|
||||
|
||||
$this->db_connect_id = ($new_link) ? @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8') : (($this->persistency) ? @ociplogon($this->user, $sqlpassword, $connect, 'UTF8') : @ocilogon($this->user, $sqlpassword, $connect, 'UTF8'));
|
||||
if ($new_link)
|
||||
{
|
||||
if (!function_exists('ocinlogon'))
|
||||
{
|
||||
$this->connect_error = 'ocinlogon function does not exist, is oci extension installed?';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
$this->db_connect_id = @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8');
|
||||
}
|
||||
else if ($this->persistency)
|
||||
{
|
||||
if (!function_exists('ociplogon'))
|
||||
{
|
||||
$this->connect_error = 'ociplogon function does not exist, is oci extension installed?';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
$this->db_connect_id = @ociplogon($this->user, $sqlpassword, $connect, 'UTF8');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!function_exists('ocilogon'))
|
||||
{
|
||||
$this->connect_error = 'ocilogon function does not exist, is oci extension installed?';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
$this->db_connect_id = @ocilogon($this->user, $sqlpassword, $connect, 'UTF8');
|
||||
}
|
||||
|
||||
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
|
||||
}
|
||||
|
@ -646,17 +671,27 @@ class dbal_oracle extends dbal
|
|||
*/
|
||||
function _sql_error()
|
||||
{
|
||||
$error = @ocierror();
|
||||
$error = (!$error) ? @ocierror($this->query_result) : $error;
|
||||
$error = (!$error) ? @ocierror($this->db_connect_id) : $error;
|
||||
|
||||
if ($error)
|
||||
if (function_exists('ocierror'))
|
||||
{
|
||||
$this->last_error_result = $error;
|
||||
$error = @ocierror();
|
||||
$error = (!$error) ? @ocierror($this->query_result) : $error;
|
||||
$error = (!$error) ? @ocierror($this->db_connect_id) : $error;
|
||||
|
||||
if ($error)
|
||||
{
|
||||
$this->last_error_result = $error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
|
||||
$error = array(
|
||||
'message' => $this->connect_error,
|
||||
'code' => '',
|
||||
);
|
||||
}
|
||||
|
||||
return $error;
|
|
@ -15,19 +15,12 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
||||
|
||||
if (!class_exists('phpbb_error_collector'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/error_collector.' . $phpEx);
|
||||
}
|
||||
|
||||
/**
|
||||
* PostgreSQL Database Abstraction Layer
|
||||
* Minimum Requirement is Version 7.3+
|
||||
* @package dbal
|
||||
*/
|
||||
class dbal_postgres extends dbal
|
||||
class phpbb_db_driver_postgres extends phpbb_db_driver
|
||||
{
|
||||
var $last_query_text = '';
|
||||
var $connect_error = '';
|
|
@ -15,15 +15,15 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
||||
|
||||
/**
|
||||
* Sqlite Database Abstraction Layer
|
||||
* Minimum Requirement: 2.8.2+
|
||||
* @package dbal
|
||||
*/
|
||||
class dbal_sqlite extends dbal
|
||||
class phpbb_db_driver_sqlite extends phpbb_db_driver
|
||||
{
|
||||
var $connect_error = '';
|
||||
|
||||
/**
|
||||
* Connect to server
|
||||
*/
|
||||
|
@ -35,7 +35,24 @@ class dbal_sqlite extends dbal
|
|||
$this->dbname = $database;
|
||||
|
||||
$error = '';
|
||||
$this->db_connect_id = ($this->persistency) ? @sqlite_popen($this->server, 0666, $error) : @sqlite_open($this->server, 0666, $error);
|
||||
if ($this->persistency)
|
||||
{
|
||||
if (!function_exists('sqlite_popen'))
|
||||
{
|
||||
$this->connect_error = 'sqlite_popen function does not exist, is sqlite extension installed?';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
$this->db_connect_id = @sqlite_popen($this->server, 0666, $error);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!function_exists('sqlite_open'))
|
||||
{
|
||||
$this->connect_error = 'sqlite_open function does not exist, is sqlite extension installed?';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
$this->db_connect_id = @sqlite_open($this->server, 0666, $error);
|
||||
}
|
||||
|
||||
if ($this->db_connect_id)
|
||||
{
|
||||
|
@ -280,10 +297,22 @@ class dbal_sqlite extends dbal
|
|||
*/
|
||||
function _sql_error()
|
||||
{
|
||||
return array(
|
||||
'message' => @sqlite_error_string(@sqlite_last_error($this->db_connect_id)),
|
||||
'code' => @sqlite_last_error($this->db_connect_id)
|
||||
);
|
||||
if (function_exists('sqlite_error_string'))
|
||||
{
|
||||
$error = array(
|
||||
'message' => @sqlite_error_string(@sqlite_last_error($this->db_connect_id)),
|
||||
'code' => @sqlite_last_error($this->db_connect_id),
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = array(
|
||||
'message' => $this->connect_error,
|
||||
'code' => '',
|
||||
);
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
|
@ -43,8 +43,8 @@ class phpbb_di_extension_config extends Extension
|
|||
require($this->config_file);
|
||||
|
||||
$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('cache.driver.class', $this->convert_30_acm_type($acm_type));
|
||||
$container->setParameter('dbal.driver.class', phpbb_convert_30_dbms_to_31($dbms));
|
||||
$container->setParameter('dbal.dbhost', $dbhost);
|
||||
$container->setParameter('dbal.dbuser', $dbuser);
|
||||
$container->setParameter('dbal.dbpasswd', $dbpasswd);
|
||||
|
@ -66,12 +66,12 @@ class phpbb_di_extension_config extends Extension
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert old (3.0) values to 3.1 class names
|
||||
* Convert 3.0 ACM type to 3.1 cache driver class name
|
||||
*
|
||||
* @param style $acm_type ACM type
|
||||
* @return ACM type class
|
||||
* @param string $acm_type ACM type
|
||||
* @return cache driver class
|
||||
*/
|
||||
protected function fix_acm_type($acm_type)
|
||||
protected function convert_30_acm_type($acm_type)
|
||||
{
|
||||
if (preg_match('#^[a-z]+$#', $acm_type))
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ class phpbb_di_service_collection extends ArrayObject
|
|||
public function add($name)
|
||||
{
|
||||
$task = $this->container->get($name);
|
||||
$task->set_name($name);
|
||||
|
||||
$this->offsetSet($name, $task);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class phpbb_extension_manager
|
|||
/**
|
||||
* Creates a manager and loads information from database
|
||||
*
|
||||
* @param dbal $db A database connection
|
||||
* @param phpbb_db_driver $db A database connection
|
||||
* @param phpbb_config $config phpbb_config
|
||||
* @param string $extension_table The name of the table holding extensions
|
||||
* @param string $phpbb_root_path Path to the phpbb includes directory.
|
||||
|
@ -42,7 +42,7 @@ class phpbb_extension_manager
|
|||
* @param phpbb_cache_driver_interface $cache A cache instance or null
|
||||
* @param string $cache_name The name of the cache variable, defaults to _ext
|
||||
*/
|
||||
public function __construct(dbal $db, phpbb_config $config, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext')
|
||||
public function __construct(phpbb_db_driver $db, phpbb_config $config, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext')
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->db = $db;
|
||||
|
|
|
@ -34,12 +34,12 @@ class phpbb_extension_metadata_manager
|
|||
/**
|
||||
* Creates the metadata manager
|
||||
*
|
||||
* @param dbal $db A database connection
|
||||
* @param phpbb_db_driver $db A database connection
|
||||
* @param string $extension_manager An instance of the phpbb extension manager
|
||||
* @param string $phpbb_root_path Path to the phpbb includes directory.
|
||||
* @param string $phpEx php file extension
|
||||
*/
|
||||
public function __construct($ext_name, dbal $db, phpbb_extension_manager $extension_manager, $phpbb_root_path, $phpEx = '.php', phpbb_template $template, phpbb_config $config)
|
||||
public function __construct($ext_name, phpbb_db_driver $db, phpbb_extension_manager $extension_manager, $phpbb_root_path, $phpEx = '.php', phpbb_template $template, phpbb_config $config)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->db = $db;
|
||||
|
|
|
@ -4870,13 +4870,108 @@ function phpbb_http_login($param)
|
|||
trigger_error('NOT_AUTHORISED');
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes and quotes a string for use as an HTML/XML attribute value.
|
||||
*
|
||||
* This is a port of Python xml.sax.saxutils quoteattr.
|
||||
*
|
||||
* The function will attempt to choose a quote character in such a way as to
|
||||
* avoid escaping quotes in the string. If this is not possible the string will
|
||||
* be wrapped in double quotes and double quotes will be escaped.
|
||||
*
|
||||
* @param string $data The string to be escaped
|
||||
* @param array $entities Associative array of additional entities to be escaped
|
||||
* @return string Escaped and quoted string
|
||||
*/
|
||||
function phpbb_quoteattr($data, $entities = null)
|
||||
{
|
||||
$data = str_replace('&', '&', $data);
|
||||
$data = str_replace('>', '>', $data);
|
||||
$data = str_replace('<', '<', $data);
|
||||
|
||||
$data = str_replace("\n", ' ', $data);
|
||||
$data = str_replace("\r", ' ', $data);
|
||||
$data = str_replace("\t", '	', $data);
|
||||
|
||||
if (!empty($entities))
|
||||
{
|
||||
$data = str_replace(array_keys($entities), array_values($entities), $data);
|
||||
}
|
||||
|
||||
if (strpos($data, '"') !== false)
|
||||
{
|
||||
if (strpos($data, "'") !== false)
|
||||
{
|
||||
$data = '"' . str_replace('"', '"', $data) . '"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = "'" . $data . "'";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = '"' . $data . '"';
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts query string (GET) parameters in request into hidden fields.
|
||||
*
|
||||
* Useful for forwarding GET parameters when submitting forms with GET method.
|
||||
*
|
||||
* It is possible to omit some of the GET parameters, which is useful if
|
||||
* they are specified in the form being submitted.
|
||||
*
|
||||
* sid is always omitted.
|
||||
*
|
||||
* @param phpbb_request $request Request object
|
||||
* @param array $exclude A list of variable names that should not be forwarded
|
||||
* @return string HTML with hidden fields
|
||||
*/
|
||||
function phpbb_build_hidden_fields_for_query_params($request, $exclude = null)
|
||||
{
|
||||
$names = $request->variable_names(phpbb_request_interface::GET);
|
||||
$hidden = '';
|
||||
foreach ($names as $name)
|
||||
{
|
||||
// Sessions are dealt with elsewhere, omit sid always
|
||||
if ($name == 'sid')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Omit any additional parameters requested
|
||||
if (!empty($exclude) && in_array($name, $exclude))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$escaped_name = phpbb_quoteattr($name);
|
||||
|
||||
// Note: we might retrieve the variable from POST or cookies
|
||||
// here. To avoid exposing cookies, skip variables that are
|
||||
// overwritten somewhere other than GET entirely.
|
||||
$value = $request->variable($name, '', true);
|
||||
$get_value = $request->variable($name, '', true, phpbb_request_interface::GET);
|
||||
if ($value === $get_value)
|
||||
{
|
||||
$escaped_value = phpbb_quoteattr($value);
|
||||
$hidden .= "<input type='hidden' name=$escaped_name value=$escaped_value />";
|
||||
}
|
||||
}
|
||||
return $hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate page header
|
||||
*/
|
||||
function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum')
|
||||
{
|
||||
global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path;
|
||||
global $phpbb_dispatcher;
|
||||
global $phpbb_dispatcher, $request;
|
||||
|
||||
if (defined('HEADER_INC'))
|
||||
{
|
||||
|
@ -5065,6 +5160,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
|
|||
$timezone_name = $user->lang['timezones'][$timezone_name];
|
||||
}
|
||||
|
||||
$hidden_fields_for_jumpbox = phpbb_build_hidden_fields_for_query_params($request, array('f'));
|
||||
|
||||
// The following assigns all _common_ variables that may be used at any point in a template.
|
||||
$template->assign_vars(array(
|
||||
'SITENAME' => $config['sitename'],
|
||||
|
@ -5079,6 +5176,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
|
|||
'RECORD_USERS' => $l_online_record,
|
||||
'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text,
|
||||
'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread,
|
||||
'HIDDEN_FIELDS_FOR_JUMPBOX' => $hidden_fields_for_jumpbox,
|
||||
|
||||
'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'],
|
||||
'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'],
|
||||
|
@ -5428,6 +5526,52 @@ function phpbb_to_numeric($input)
|
|||
return ($input > PHP_INT_MAX) ? (float) $input : (int) $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert either 3.0 dbms or 3.1 db driver class name to 3.1 db driver class name.
|
||||
*
|
||||
* If $dbms is a valid 3.1 db driver class name, returns it unchanged.
|
||||
* Otherwise prepends phpbb_db_driver_ to the dbms to convert a 3.0 dbms
|
||||
* to 3.1 db driver class name.
|
||||
*
|
||||
* @param string $dbms dbms parameter
|
||||
* @return db driver class
|
||||
*/
|
||||
function phpbb_convert_30_dbms_to_31($dbms)
|
||||
{
|
||||
// Note: this check is done first because mysqli extension
|
||||
// supplies a mysqli class, and class_exists($dbms) would return
|
||||
// true for mysqli class.
|
||||
// However, per the docblock any valid 3.1 driver name should be
|
||||
// recognized by this function, and have priority over 3.0 dbms.
|
||||
if (class_exists('phpbb_db_driver_' . $dbms))
|
||||
{
|
||||
return 'phpbb_db_driver_' . $dbms;
|
||||
}
|
||||
|
||||
if (class_exists($dbms))
|
||||
{
|
||||
// Additionally we could check that $dbms extends phpbb_db_driver.
|
||||
// http://php.net/manual/en/class.reflectionclass.php
|
||||
// Beware of possible performance issues:
|
||||
// http://stackoverflow.com/questions/294582/php-5-reflection-api-performance
|
||||
// We could check for interface implementation in all paths or
|
||||
// only when we do not prepend phpbb_db_driver_.
|
||||
|
||||
/*
|
||||
$reflection = new \ReflectionClass($dbms);
|
||||
|
||||
if ($reflection->isSubclassOf('phpbb_db_driver'))
|
||||
{
|
||||
return $dbms;
|
||||
}
|
||||
*/
|
||||
|
||||
return $dbms;
|
||||
}
|
||||
|
||||
throw new \RuntimeException("You have specified an invalid dbms driver: $dbms");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Symfony Request object from phpbb_request object
|
||||
*
|
||||
|
|
206
phpBB/includes/functions_database_helper.php
Normal file
206
phpBB/includes/functions_database_helper.php
Normal file
|
@ -0,0 +1,206 @@
|
|||
<?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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates rows in given table from a set of values to a new value.
|
||||
* If this results in rows violating uniqueness constraints, the duplicate
|
||||
* rows are eliminated.
|
||||
*
|
||||
* The only supported table is bookmarks.
|
||||
*
|
||||
* @param dbal $db Database object
|
||||
* @param string $table Table on which to perform the update
|
||||
* @param string $column Column whose values to change
|
||||
* @param array $from_values An array of values that should be changed
|
||||
* @param int $to_value The new value
|
||||
* @return null
|
||||
*/
|
||||
function phpbb_update_rows_avoiding_duplicates($db, $table, $column, $from_values, $to_value)
|
||||
{
|
||||
$sql = "SELECT $column, user_id
|
||||
FROM $table
|
||||
WHERE " . $db->sql_in_set($column, $from_values);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$old_user_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$old_user_ids[$row[$column]][] = (int) $row['user_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT $column, user_id
|
||||
FROM $table
|
||||
WHERE $column = " . (int) $to_value;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$new_user_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$new_user_ids[$row[$column]][] = (int) $row['user_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$queries = array();
|
||||
foreach ($from_values as $from_value)
|
||||
{
|
||||
if (!isset($old_user_ids[$from_value]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (empty($new_user_ids))
|
||||
{
|
||||
$sql = "UPDATE $table
|
||||
SET $column = " . (int) $to_value . "
|
||||
WHERE $column = '" . $db->sql_escape($from_value) . "'";
|
||||
$queries[] = $sql;
|
||||
}
|
||||
else
|
||||
{
|
||||
$different_user_ids = array_diff($old_user_ids[$from_value], $new_user_ids[$to_value]);
|
||||
if (!empty($different_user_ids))
|
||||
{
|
||||
$sql = "UPDATE $table
|
||||
SET $column = " . (int) $to_value . "
|
||||
WHERE $column = '" . $db->sql_escape($from_value) . "'
|
||||
AND " . $db->sql_in_set('user_id', $different_user_ids);
|
||||
$queries[] = $sql;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($queries))
|
||||
{
|
||||
$db->sql_transaction('begin');
|
||||
|
||||
foreach ($queries as $sql)
|
||||
{
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM $table
|
||||
WHERE " . $db->sql_in_set($column, $from_values);
|
||||
$db->sql_query($sql);
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates rows in given table from a set of values to a new value.
|
||||
* If this results in rows violating uniqueness constraints, the duplicate
|
||||
* rows are merged respecting notify_status (0 takes precedence over 1).
|
||||
*
|
||||
* The only supported table is topics_watch.
|
||||
*
|
||||
* @param dbal $db Database object
|
||||
* @param string $table Table on which to perform the update
|
||||
* @param string $column Column whose values to change
|
||||
* @param array $from_values An array of values that should be changed
|
||||
* @param int $to_value The new value
|
||||
* @return null
|
||||
*/
|
||||
function phpbb_update_rows_avoiding_duplicates_notify_status($db, $table, $column, $from_values, $to_value)
|
||||
{
|
||||
$sql = "SELECT $column, user_id, notify_status
|
||||
FROM $table
|
||||
WHERE " . $db->sql_in_set($column, $from_values);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$old_user_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$old_user_ids[(int) $row['notify_status']][$row[$column]][] = (int) $row['user_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "SELECT $column, user_id
|
||||
FROM $table
|
||||
WHERE $column = " . (int) $to_value;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$new_user_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$new_user_ids[$row[$column]][] = (int) $row['user_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$queries = array();
|
||||
$extra_updates = array(
|
||||
0 => 'notify_status = 0',
|
||||
1 => '',
|
||||
);
|
||||
foreach ($from_values as $from_value)
|
||||
{
|
||||
foreach ($extra_updates as $notify_status => $extra_update)
|
||||
{
|
||||
if (!isset($old_user_ids[$notify_status][$from_value]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (empty($new_user_ids))
|
||||
{
|
||||
$sql = "UPDATE $table
|
||||
SET $column = " . (int) $to_value . "
|
||||
WHERE $column = '" . $db->sql_escape($from_value) . "'";
|
||||
$queries[] = $sql;
|
||||
}
|
||||
else
|
||||
{
|
||||
$different_user_ids = array_diff($old_user_ids[$notify_status][$from_value], $new_user_ids[$to_value]);
|
||||
if (!empty($different_user_ids))
|
||||
{
|
||||
$sql = "UPDATE $table
|
||||
SET $column = " . (int) $to_value . "
|
||||
WHERE $column = '" . $db->sql_escape($from_value) . "'
|
||||
AND " . $db->sql_in_set('user_id', $different_user_ids);
|
||||
$queries[] = $sql;
|
||||
}
|
||||
|
||||
if ($extra_update)
|
||||
{
|
||||
$same_user_ids = array_diff($old_user_ids[$notify_status][$from_value], $different_user_ids);
|
||||
if (!empty($same_user_ids))
|
||||
{
|
||||
$sql = "UPDATE $table
|
||||
SET $extra_update
|
||||
WHERE $column = '" . (int) $to_value . "'
|
||||
AND " . $db->sql_in_set('user_id', $same_user_ids);
|
||||
$queries[] = $sql;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($queries))
|
||||
{
|
||||
$db->sql_transaction('begin');
|
||||
|
||||
foreach ($queries as $sql)
|
||||
{
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM $table
|
||||
WHERE " . $db->sql_in_set($column, $from_values);
|
||||
$db->sql_query($sql);
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
}
|
||||
}
|
|
@ -596,7 +596,7 @@ function phpbb_parse_range_request($request_array, $filesize)
|
|||
/**
|
||||
* Increments the download count of all provided attachments
|
||||
*
|
||||
* @param dbal $db The database object
|
||||
* @param phpbb_db_driver $db The database object
|
||||
* @param array|int $ids The attach_id of each attachment
|
||||
*
|
||||
* @return null
|
||||
|
@ -617,7 +617,7 @@ function phpbb_increment_downloads($db, $ids)
|
|||
/**
|
||||
* Handles authentication when downloading attachments from a post or topic
|
||||
*
|
||||
* @param dbal $db The database object
|
||||
* @param phpbb_db_driver $db The database object
|
||||
* @param phpbb_auth $auth The authentication object
|
||||
* @param int $topic_id The id of the topic that we are downloading from
|
||||
*
|
||||
|
@ -651,7 +651,7 @@ function phpbb_download_handle_forum_auth($db, $auth, $topic_id)
|
|||
/**
|
||||
* Handles authentication when downloading attachments from PMs
|
||||
*
|
||||
* @param dbal $db The database object
|
||||
* @param phpbb_db_driver $db The database object
|
||||
* @param phpbb_auth $auth The authentication object
|
||||
* @param int $user_id The user id
|
||||
* @param int $msg_id The id of the PM that we are downloading from
|
||||
|
@ -678,7 +678,7 @@ function phpbb_download_handle_pm_auth($db, $auth, $user_id, $msg_id)
|
|||
/**
|
||||
* Checks whether a user can download from a particular PM
|
||||
*
|
||||
* @param dbal $db The database object
|
||||
* @param phpbb_db_driver $db The database object
|
||||
* @param int $user_id The user id
|
||||
* @param int $msg_id The id of the PM that we are downloading from
|
||||
*
|
||||
|
|
|
@ -28,7 +28,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
|
|||
'SCHEMA' => 'firebird',
|
||||
'MODULE' => 'interbase',
|
||||
'DELIM' => ';;',
|
||||
'DRIVER' => 'firebird',
|
||||
'DRIVER' => 'phpbb_db_driver_firebird',
|
||||
'AVAILABLE' => true,
|
||||
'2.0.x' => false,
|
||||
),
|
||||
|
@ -37,7 +37,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
|
|||
'SCHEMA' => 'mysql_41',
|
||||
'MODULE' => 'mysqli',
|
||||
'DELIM' => ';',
|
||||
'DRIVER' => 'mysqli',
|
||||
'DRIVER' => 'phpbb_db_driver_mysqli',
|
||||
'AVAILABLE' => true,
|
||||
'2.0.x' => true,
|
||||
),
|
||||
|
@ -46,7 +46,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
|
|||
'SCHEMA' => 'mysql',
|
||||
'MODULE' => 'mysql',
|
||||
'DELIM' => ';',
|
||||
'DRIVER' => 'mysql',
|
||||
'DRIVER' => 'phpbb_db_driver_mysql',
|
||||
'AVAILABLE' => true,
|
||||
'2.0.x' => true,
|
||||
),
|
||||
|
@ -55,7 +55,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
|
|||
'SCHEMA' => 'mssql',
|
||||
'MODULE' => 'mssql',
|
||||
'DELIM' => 'GO',
|
||||
'DRIVER' => 'mssql',
|
||||
'DRIVER' => 'phpbb_db_driver_mssql',
|
||||
'AVAILABLE' => true,
|
||||
'2.0.x' => true,
|
||||
),
|
||||
|
@ -64,7 +64,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
|
|||
'SCHEMA' => 'mssql',
|
||||
'MODULE' => 'odbc',
|
||||
'DELIM' => 'GO',
|
||||
'DRIVER' => 'mssql_odbc',
|
||||
'DRIVER' => 'phpbb_db_driver_mssql_odbc',
|
||||
'AVAILABLE' => true,
|
||||
'2.0.x' => true,
|
||||
),
|
||||
|
@ -73,7 +73,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
|
|||
'SCHEMA' => 'mssql',
|
||||
'MODULE' => 'sqlsrv',
|
||||
'DELIM' => 'GO',
|
||||
'DRIVER' => 'mssqlnative',
|
||||
'DRIVER' => 'phpbb_db_driver_mssqlnative',
|
||||
'AVAILABLE' => true,
|
||||
'2.0.x' => false,
|
||||
),
|
||||
|
@ -82,7 +82,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
|
|||
'SCHEMA' => 'oracle',
|
||||
'MODULE' => 'oci8',
|
||||
'DELIM' => '/',
|
||||
'DRIVER' => 'oracle',
|
||||
'DRIVER' => 'phpbb_db_driver_oracle',
|
||||
'AVAILABLE' => true,
|
||||
'2.0.x' => false,
|
||||
),
|
||||
|
@ -91,7 +91,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
|
|||
'SCHEMA' => 'postgres',
|
||||
'MODULE' => 'pgsql',
|
||||
'DELIM' => ';',
|
||||
'DRIVER' => 'postgres',
|
||||
'DRIVER' => 'phpbb_db_driver_postgres',
|
||||
'AVAILABLE' => true,
|
||||
'2.0.x' => true,
|
||||
),
|
||||
|
@ -100,7 +100,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
|
|||
'SCHEMA' => 'sqlite',
|
||||
'MODULE' => 'sqlite',
|
||||
'DELIM' => ';',
|
||||
'DRIVER' => 'sqlite',
|
||||
'DRIVER' => 'phpbb_db_driver_sqlite',
|
||||
'AVAILABLE' => true,
|
||||
'2.0.x' => false,
|
||||
),
|
||||
|
@ -205,26 +205,19 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
|
|||
|
||||
$dbms = $dbms_details['DRIVER'];
|
||||
|
||||
if ($load_dbal)
|
||||
{
|
||||
// Include the DB layer
|
||||
include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
||||
}
|
||||
|
||||
// Instantiate it and set return on error true
|
||||
$sql_db = 'dbal_' . $dbms;
|
||||
$db = new $sql_db();
|
||||
$db = new $dbms();
|
||||
$db->sql_return_on_error(true);
|
||||
|
||||
// Check that we actually have a database name before going any further.....
|
||||
if ($dbms_details['DRIVER'] != 'sqlite' && $dbms_details['DRIVER'] != 'oracle' && $dbname === '')
|
||||
if ($dbms_details['DRIVER'] != 'phpbb_db_driver_sqlite' && $dbms_details['DRIVER'] != 'phpbb_db_driver_oracle' && $dbname === '')
|
||||
{
|
||||
$error[] = $lang['INST_ERR_DB_NO_NAME'];
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea
|
||||
if ($dbms_details['DRIVER'] == 'sqlite' && stripos(phpbb_realpath($dbhost), phpbb_realpath('../')) === 0)
|
||||
if ($dbms_details['DRIVER'] == 'phpbb_db_driver_sqlite' && stripos(phpbb_realpath($dbhost), phpbb_realpath('../')) === 0)
|
||||
{
|
||||
$error[] = $lang['INST_ERR_DB_FORUM_PATH'];
|
||||
return false;
|
||||
|
@ -233,8 +226,8 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
|
|||
// Check the prefix length to ensure that index names are not too long and does not contain invalid characters
|
||||
switch ($dbms_details['DRIVER'])
|
||||
{
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
case 'phpbb_db_driver_mysql':
|
||||
case 'phpbb_db_driver_mysqli':
|
||||
if (strspn($table_prefix, '-./\\') !== 0)
|
||||
{
|
||||
$error[] = $lang['INST_ERR_PREFIX_INVALID'];
|
||||
|
@ -243,22 +236,22 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
|
|||
|
||||
// no break;
|
||||
|
||||
case 'postgres':
|
||||
case 'phpbb_db_driver_postgres':
|
||||
$prefix_length = 36;
|
||||
break;
|
||||
|
||||
case 'mssql':
|
||||
case 'mssql_odbc':
|
||||
case 'mssqlnative':
|
||||
case 'phpbb_db_driver_mssql':
|
||||
case 'phpbb_db_driver_mssql_odbc':
|
||||
case 'phpbb_db_driver_mssqlnative':
|
||||
$prefix_length = 90;
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'phpbb_db_driver_sqlite':
|
||||
$prefix_length = 200;
|
||||
break;
|
||||
|
||||
case 'firebird':
|
||||
case 'oracle':
|
||||
case 'phpbb_db_driver_firebird':
|
||||
case 'phpbb_db_driver_oracle':
|
||||
$prefix_length = 6;
|
||||
break;
|
||||
}
|
||||
|
@ -296,21 +289,21 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
|
|||
// Make sure that the user has selected a sensible DBAL for the DBMS actually installed
|
||||
switch ($dbms_details['DRIVER'])
|
||||
{
|
||||
case 'mysqli':
|
||||
case 'phpbb_db_driver_mysqli':
|
||||
if (version_compare(mysqli_get_server_info($db->db_connect_id), '4.1.3', '<'))
|
||||
{
|
||||
$error[] = $lang['INST_ERR_DB_NO_MYSQLI'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'phpbb_db_driver_sqlite':
|
||||
if (version_compare(sqlite_libversion(), '2.8.2', '<'))
|
||||
{
|
||||
$error[] = $lang['INST_ERR_DB_NO_SQLITE'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'firebird':
|
||||
case 'phpbb_db_driver_firebird':
|
||||
// check the version of FB, use some hackery if we can't get access to the server info
|
||||
if ($db->service_handle !== false && function_exists('ibase_server_info'))
|
||||
{
|
||||
|
@ -391,7 +384,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
|
|||
}
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
case 'phpbb_db_driver_oracle':
|
||||
if ($unicode_check)
|
||||
{
|
||||
$sql = "SELECT *
|
||||
|
@ -413,7 +406,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
|
|||
}
|
||||
break;
|
||||
|
||||
case 'postgres':
|
||||
case 'phpbb_db_driver_postgres':
|
||||
if ($unicode_check)
|
||||
{
|
||||
$sql = "SHOW server_encoding;";
|
||||
|
|
|
@ -210,7 +210,7 @@ class messenger
|
|||
{
|
||||
$style_resource_locator = new phpbb_style_resource_locator();
|
||||
$style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider());
|
||||
$tpl = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, new phpbb_template_context());
|
||||
$tpl = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, new phpbb_template_context(), $phpbb_extension_manager);
|
||||
$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $tpl);
|
||||
|
||||
$this->tpl_msg[$template_lang . $template_file] = $tpl;
|
||||
|
@ -231,7 +231,7 @@ class messenger
|
|||
}
|
||||
}
|
||||
|
||||
$style->set_custom_style($template_lang . '_email', array($template_path, $fallback_template_path), '');
|
||||
$style->set_custom_style($template_lang . '_email', array($template_path, $fallback_template_path), array(), '');
|
||||
|
||||
$tpl->set_filenames(array(
|
||||
'body' => $template_file . '.txt',
|
||||
|
|
|
@ -48,7 +48,7 @@ class phpbb_lock_db
|
|||
|
||||
/**
|
||||
* A database connection
|
||||
* @var dbal
|
||||
* @var phpbb_db_driver
|
||||
*/
|
||||
private $db;
|
||||
|
||||
|
@ -59,9 +59,9 @@ class phpbb_lock_db
|
|||
*
|
||||
* @param string $config_name A config variable to be used for locking
|
||||
* @param array $config The phpBB configuration
|
||||
* @param dbal $db A database connection
|
||||
* @param phpbb_db_driver $db A database connection
|
||||
*/
|
||||
public function __construct($config_name, phpbb_config $config, dbal $db)
|
||||
public function __construct($config_name, phpbb_config $config, phpbb_db_driver $db)
|
||||
{
|
||||
$this->config_name = $config_name;
|
||||
$this->config = $config;
|
||||
|
|
|
@ -430,13 +430,12 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)
|
|||
// Message and return links
|
||||
$success_msg = 'POSTS_MERGED_SUCCESS';
|
||||
|
||||
// If the topic no longer exist, we will update the topic watch table.
|
||||
// To not let it error out on users watching both topics, we just return on an error...
|
||||
$db->sql_return_on_error(true);
|
||||
$db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids));
|
||||
$db->sql_return_on_error(false);
|
||||
|
||||
$db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids));
|
||||
// Update the topic watch table.
|
||||
if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_database_helper.' . $phpEx);
|
||||
}
|
||||
phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id);
|
||||
|
||||
// Link to the new topic
|
||||
$return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>');
|
||||
|
|
|
@ -624,12 +624,11 @@ function merge_posts($topic_id, $to_topic_id)
|
|||
else
|
||||
{
|
||||
// If the topic no longer exist, we will update the topic watch table.
|
||||
// To not let it error out on users watching both topics, we just return on an error...
|
||||
$db->sql_return_on_error(true);
|
||||
$db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE topic_id = ' . (int) $topic_id);
|
||||
$db->sql_return_on_error(false);
|
||||
|
||||
$db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id = ' . (int) $topic_id);
|
||||
if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_database_helper.' . $phpEx);
|
||||
}
|
||||
phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id);
|
||||
}
|
||||
|
||||
// Link to the new topic
|
||||
|
|
|
@ -260,6 +260,8 @@ class phpbb_questionnaire_phpbb_data_provider
|
|||
include("{$phpbb_root_path}config.$phpEx");
|
||||
unset($dbhost, $dbport, $dbname, $dbuser, $dbpasswd); // Just a precaution
|
||||
|
||||
$dbms = phpbb_convert_30_dbms_to_31($dbms);
|
||||
|
||||
// Only send certain config vars
|
||||
$config_vars = array(
|
||||
'active_sessions' => true,
|
||||
|
|
|
@ -41,8 +41,8 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
|
|||
protected $config;
|
||||
|
||||
/**
|
||||
* DBAL object
|
||||
* @var dbal
|
||||
* Database connection
|
||||
* @var phpbb_db_driver
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
|
|
|
@ -85,8 +85,8 @@ class phpbb_search_fulltext_native extends phpbb_search_base
|
|||
protected $config;
|
||||
|
||||
/**
|
||||
* DBAL object
|
||||
* @var dbal
|
||||
* Database connection
|
||||
* @var phpbb_db_driver
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
|
|
|
@ -66,8 +66,8 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
|||
protected $config;
|
||||
|
||||
/**
|
||||
* DBAL object
|
||||
* @var dbal
|
||||
* Database connection
|
||||
* @var phpbb_db_driver
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
|
|
|
@ -84,8 +84,8 @@ class phpbb_search_fulltext_sphinx
|
|||
protected $config;
|
||||
|
||||
/**
|
||||
* DBAL object
|
||||
* @var dbal
|
||||
* Database connection
|
||||
* @var phpbb_db_driver
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
|
|
|
@ -91,16 +91,22 @@ class phpbb_style
|
|||
{
|
||||
$style_path = $this->user->style['style_path'];
|
||||
$style_dirs = ($this->user->style['style_parent_id']) ? array_reverse(explode('/', $this->user->style['style_parent_tree'])) : array();
|
||||
$paths = array($this->get_style_path($style_path));
|
||||
|
||||
$names = array($style_path);
|
||||
foreach ($style_dirs as $dir)
|
||||
{
|
||||
$paths[] = $this->get_style_path($dir);
|
||||
$names[] = $dir;
|
||||
}
|
||||
// Add 'all' path, used as last fallback path by events and extensions
|
||||
//$names[] = 'all';
|
||||
|
||||
$paths = array();
|
||||
foreach ($names as $name)
|
||||
{
|
||||
$paths[] = $this->get_style_path($name);
|
||||
}
|
||||
|
||||
// Add 'all' path, used as last fallback path by hooks and extensions
|
||||
$paths[] = $this->get_style_path('all');
|
||||
|
||||
return $this->set_custom_style($style_path, $paths);
|
||||
return $this->set_custom_style($style_path, $paths, $names);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,18 +116,27 @@ class phpbb_style
|
|||
*
|
||||
* @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver"
|
||||
* @param array or string $paths Array of style paths, relative to current root directory
|
||||
* @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used.
|
||||
* @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/).
|
||||
*/
|
||||
public function set_custom_style($name, $paths, $template_path = false)
|
||||
public function set_custom_style($name, $paths, $names = array(), $template_path = false)
|
||||
{
|
||||
if (is_string($paths))
|
||||
{
|
||||
$paths = array($paths);
|
||||
}
|
||||
|
||||
if (empty($names))
|
||||
{
|
||||
$names = array($name);
|
||||
}
|
||||
$this->names = $names;
|
||||
|
||||
$this->provider->set_styles($paths);
|
||||
$this->locator->set_paths($this->provider);
|
||||
|
||||
$this->template->set_style_names($names);
|
||||
|
||||
if ($template_path !== false)
|
||||
{
|
||||
$this->locator->set_template_path($template_path);
|
||||
|
|
|
@ -35,16 +35,23 @@ class phpbb_template_compile
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param bool @allow_php Whether PHP code will be allowed in templates (inline PHP code, PHP tag and INCLUDEPHP tag)
|
||||
* @param bool $allow_php Whether PHP code will be allowed in templates (inline PHP code, PHP tag and INCLUDEPHP tag)
|
||||
* @param array $style_names Name of style to which the template being compiled belongs and parents in style tree order
|
||||
* @param phpbb_style_resource_locator $locator Resource locator
|
||||
* @param string $phpbb_root_path Path to phpBB root directory
|
||||
* @param phpbb_extension_manager $extension_manager Extension manager to use for finding template fragments in extensions; if null, template events will not be invoked
|
||||
* @param phpbb_user $user Current user
|
||||
*/
|
||||
public function __construct($allow_php, $locator, $phpbb_root_path)
|
||||
public function __construct($allow_php, $style_names, $locator, $phpbb_root_path, $extension_manager = null, $user = null)
|
||||
{
|
||||
$this->filter_params = array(
|
||||
'allow_php' => $allow_php,
|
||||
'style_names' => $style_names,
|
||||
'locator' => $locator,
|
||||
'phpbb_root_path' => $phpbb_root_path
|
||||
'phpbb_root_path' => $phpbb_root_path,
|
||||
'extension_manager' => $extension_manager,
|
||||
'user' => $user,
|
||||
'template_compile' => $this,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,6 +87,37 @@ class phpbb_template_filter extends php_user_filter
|
|||
*/
|
||||
private $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* Name of the style that the template being compiled and/or rendered
|
||||
* belongs to, and its parents, in inheritance tree order.
|
||||
*
|
||||
* Used to invoke style-specific template events.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $style_names;
|
||||
|
||||
/**
|
||||
* Extension manager.
|
||||
*
|
||||
* @var phpbb_extension_manager
|
||||
*/
|
||||
private $extension_manager;
|
||||
|
||||
/**
|
||||
* Current user
|
||||
*
|
||||
* @var phpbb_user
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Template compiler.
|
||||
*
|
||||
* @var phpbb_template_compile
|
||||
*/
|
||||
private $template_compile;
|
||||
|
||||
/**
|
||||
* Stream filter
|
||||
*
|
||||
|
@ -138,8 +169,10 @@ class phpbb_template_filter extends php_user_filter
|
|||
/**
|
||||
* Initializer, called on creation.
|
||||
*
|
||||
* Get the allow_php option, root directory and locator from params,
|
||||
* Get the allow_php option, style_names, root directory and locator from params,
|
||||
* which are passed to stream_filter_append.
|
||||
*
|
||||
* @return boolean Returns true
|
||||
*/
|
||||
public function onCreate()
|
||||
{
|
||||
|
@ -148,6 +181,13 @@ class phpbb_template_filter extends php_user_filter
|
|||
$this->allow_php = $this->params['allow_php'];
|
||||
$this->locator = $this->params['locator'];
|
||||
$this->phpbb_root_path = $this->params['phpbb_root_path'];
|
||||
$this->style_names = $this->params['style_names'];
|
||||
$this->extension_manager = $this->params['extension_manager'];
|
||||
if (isset($this->params['user']))
|
||||
{
|
||||
$this->user = $this->params['user'];
|
||||
}
|
||||
$this->template_compile = $this->params['template_compile'];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -229,7 +269,9 @@ class phpbb_template_filter extends php_user_filter
|
|||
}
|
||||
|
||||
/**
|
||||
* Callback for replacing matched tokens with PHP code
|
||||
* Callback for replacing matched tokens with compiled template code.
|
||||
*
|
||||
* Compiled template code is an HTML stream with embedded PHP.
|
||||
*
|
||||
* @param array $matches Regular expression matches
|
||||
* @return string compiled template code
|
||||
|
@ -317,6 +359,10 @@ class phpbb_template_filter extends php_user_filter
|
|||
return '<!-- ENDPHP -->';
|
||||
break;
|
||||
|
||||
case 'EVENT':
|
||||
return '<?php ' . $this->compile_tag_event($matches[2]) . '?>';
|
||||
break;
|
||||
|
||||
default:
|
||||
return $matches[0];
|
||||
break;
|
||||
|
@ -835,6 +881,97 @@ class phpbb_template_filter extends php_user_filter
|
|||
return "\$_template->_php_include('$tag_args');";
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile EVENT tag.
|
||||
*
|
||||
* $tag_args should be a single string identifying the event.
|
||||
* The event name can contain letters, numbers and underscores only.
|
||||
* If an invalid event name is specified, an E_USER_ERROR will be
|
||||
* triggered.
|
||||
*
|
||||
* Event tags are only functional when the template engine has
|
||||
* an instance of the extension manager. Extension manager would
|
||||
* be called upon to find all extensions listening for the specified
|
||||
* event, and to obtain additional template fragments. All such
|
||||
* template fragments will be compiled and included in the generated
|
||||
* compiled template code for the current template being compiled.
|
||||
*
|
||||
* The above means that whenever an extension is enabled or disabled,
|
||||
* template cache should be cleared in order to update the compiled
|
||||
* template code for the active set of template event listeners.
|
||||
*
|
||||
* This also means that extensions cannot return different template
|
||||
* fragments at different times. Once templates are compiled, changing
|
||||
* such template fragments would have no effect.
|
||||
*
|
||||
* @param string $tag_args EVENT tag arguments, as a string - for EVENT this is the event name
|
||||
* @return string compiled template code
|
||||
*/
|
||||
private function compile_tag_event($tag_args)
|
||||
{
|
||||
if (!preg_match('/^\w+$/', $tag_args))
|
||||
{
|
||||
// The event location is improperly formatted,
|
||||
if ($this->user)
|
||||
{
|
||||
trigger_error($this->user->lang('ERR_TEMPLATE_EVENT_LOCATION', $tag_args), E_USER_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
trigger_error(sprintf('The specified template event location <em>[%s]</em> is improperly formatted.', $tag_args), E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
$location = $tag_args;
|
||||
|
||||
if ($this->extension_manager)
|
||||
{
|
||||
$finder = $this->extension_manager->get_finder();
|
||||
|
||||
$files = $finder
|
||||
->extension_prefix($location)
|
||||
->extension_suffix('.html')
|
||||
->extension_directory("/styles/all/template")
|
||||
->get_files();
|
||||
|
||||
foreach ($this->style_names as $style_name)
|
||||
{
|
||||
$more_files = $finder
|
||||
->extension_prefix($location)
|
||||
->extension_suffix('.html')
|
||||
->extension_directory("/styles/" . $style_name . "/template")
|
||||
->get_files();
|
||||
if (!empty($more_files))
|
||||
{
|
||||
$files = array_merge($files, $more_files);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$all_compiled = '';
|
||||
foreach ($files as $file)
|
||||
{
|
||||
$compiled = $this->template_compile->compile_file($file);
|
||||
|
||||
if ($compiled === false)
|
||||
{
|
||||
if ($this->user)
|
||||
{
|
||||
trigger_error($this->user->lang('ERR_TEMPLATE_COMPILATION', phpbb_filter_root_path($file)), E_USER_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
trigger_error(sprintf('The file could not be compiled: %s', phpbb_filter_root_path($file)), E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
$all_compiled .= $compiled;
|
||||
}
|
||||
// Need spaces inside php tags as php cannot grok
|
||||
// < ?php? > sans the spaces
|
||||
return ' ?' . '>' . $all_compiled . '<?php ';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* parse expression
|
||||
* This is from Smarty
|
||||
|
|
|
@ -39,7 +39,7 @@ interface phpbb_template_locator
|
|||
* Sets the template filenames for handles. $filename_array
|
||||
* should be a hash of handle => filename pairs.
|
||||
*
|
||||
* @param array $filname_array Should be a hash of handle => filename pairs.
|
||||
* @param array $filename_array Should be a hash of handle => filename pairs.
|
||||
*/
|
||||
public function set_filenames(array $filename_array);
|
||||
|
||||
|
|
|
@ -74,6 +74,23 @@ class phpbb_template
|
|||
*/
|
||||
private $locator;
|
||||
|
||||
/**
|
||||
* Extension manager.
|
||||
*
|
||||
* @var phpbb_extension_manager
|
||||
*/
|
||||
private $extension_manager;
|
||||
|
||||
/**
|
||||
* Name of the style that the template being compiled and/or rendered
|
||||
* belongs to, and its parents, in inheritance tree order.
|
||||
*
|
||||
* Used to invoke style-specific template events.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $style_names;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -81,8 +98,9 @@ class phpbb_template
|
|||
* @param user $user current user
|
||||
* @param phpbb_template_locator $locator template locator
|
||||
* @param phpbb_template_context $context template context
|
||||
* @param phpbb_extension_manager $extension_manager extension manager, if null then template events will not be invoked
|
||||
*/
|
||||
public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_template_locator $locator, phpbb_template_context $context)
|
||||
public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_template_locator $locator, phpbb_template_context $context, phpbb_extension_manager $extension_manager = null)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
|
@ -90,12 +108,13 @@ class phpbb_template
|
|||
$this->user = $user;
|
||||
$this->locator = $locator;
|
||||
$this->context = $context;
|
||||
$this->extension_manager = $extension_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the template filenames for handles.
|
||||
*
|
||||
* @param array $filname_array Should be a hash of handle => filename pairs.
|
||||
* @param array $filename_array Should be a hash of handle => filename pairs.
|
||||
*/
|
||||
public function set_filenames(array $filename_array)
|
||||
{
|
||||
|
@ -104,6 +123,18 @@ class phpbb_template
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the style names corresponding to style hierarchy being compiled
|
||||
* and/or rendered.
|
||||
*
|
||||
* @param array $style_names List of style names in inheritance tree order
|
||||
* @return null
|
||||
*/
|
||||
public function set_style_names(array $style_names)
|
||||
{
|
||||
$this->style_names = $style_names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all variables and blocks assigned to this template.
|
||||
*/
|
||||
|
@ -282,7 +313,7 @@ class phpbb_template
|
|||
return new phpbb_template_renderer_include($output_file, $this);
|
||||
}
|
||||
|
||||
$compile = new phpbb_template_compile($this->config['tpl_allow_php'], $this->locator, $this->phpbb_root_path);
|
||||
$compile = new phpbb_template_compile($this->config['tpl_allow_php'], $this->style_names, $this->locator, $this->phpbb_root_path, $this->extension_manager, $this->user);
|
||||
|
||||
if ($compile->compile_file_to_file($source_file, $output_file) !== false)
|
||||
{
|
||||
|
|
|
@ -24,6 +24,8 @@ if (!defined('IN_PHPBB'))
|
|||
include($phpbb_root_path . 'config.' . $phpEx);
|
||||
unset($dbpasswd);
|
||||
|
||||
$dbms = phpbb_convert_30_dbms_to_31($dbms);
|
||||
|
||||
/**
|
||||
* $convertor_data provides some basic information about this convertor which is
|
||||
* used on the initial list of convertors and to populate the default settings
|
||||
|
|
|
@ -83,7 +83,6 @@ phpbb_require_updated('includes/functions_content.' . $phpEx, true);
|
|||
|
||||
require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/constants.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
|
||||
|
||||
phpbb_require_updated('includes/db/db_tools.' . $phpEx);
|
||||
|
@ -818,6 +817,70 @@ function _add_modules($modules_to_install)
|
|||
$_module->remove_cache_file();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new permission, optionally copy permission setting from another
|
||||
*
|
||||
* @param auth_admin $auth_admin auth_admin object
|
||||
* @param phpbb_db_driver $db Database object
|
||||
* @param string $permission_name Name of the permission to add
|
||||
* @param bool $is_global True is global, false is local
|
||||
* @param string $copy_from Optional permission name from which to copy
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
function _add_permission(auth_admin $auth_admin, phpbb_db_driver $db, $permission_name, $is_global = true, $copy_from = '')
|
||||
{
|
||||
// Only add a permission that don't already exist
|
||||
if (!empty($auth_admin->acl_options['id'][$permission_name]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$permission_scope = $is_global ? 'global' : 'local';
|
||||
|
||||
$result = $auth_admin->acl_add_option(array(
|
||||
$permission_scope => array($permission_name),
|
||||
));
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
|
||||
// The permission has been added, now we can copy it if needed
|
||||
if ($copy_from && isset($auth_admin->acl_options['id'][$copy_from]))
|
||||
{
|
||||
$old_id = $auth_admin->acl_options['id'][$copy_from];
|
||||
$new_id = $auth_admin->acl_options['id'][$permission_name];
|
||||
|
||||
$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);
|
||||
|
||||
foreach ($tables as $table)
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . $table . '
|
||||
WHERE auth_option_id = ' . $old_id;
|
||||
$result = _sql($sql, $errored, $error_ary);
|
||||
|
||||
$sql_ary = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$row['auth_option_id'] = $new_id;
|
||||
$sql_ary[] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (sizeof($sql_ary))
|
||||
{
|
||||
$db->sql_multi_insert($table, $sql_ary);
|
||||
}
|
||||
}
|
||||
|
||||
$auth_admin->acl_clear_prefetch();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* ADD YOUR DATABASE SCHEMA CHANGES HERE *
|
||||
*****************************************************************************/
|
||||
|
@ -2459,6 +2522,12 @@ function change_database_data(&$no_updates, $version)
|
|||
unset($next_legend);
|
||||
}
|
||||
|
||||
// Rename styles module to Customise
|
||||
$sql = 'UPDATE ' . MODULES_TABLE . "
|
||||
SET module_langname = 'ACP_CAT_CUSTOMISE'
|
||||
WHERE module_langname = 'ACP_CAT_STYLES'";
|
||||
_sql($sql, $errored, $error_ary);
|
||||
|
||||
// Install modules
|
||||
$modules_to_install = array(
|
||||
'position' => array(
|
||||
|
@ -2496,10 +2565,67 @@ function change_database_data(&$no_updates, $version)
|
|||
'auth' => '',
|
||||
'cat' => 'UCP_PROFILE',
|
||||
),
|
||||
// To add a category, the mode and basename must be empty
|
||||
// The mode is taken from the array key
|
||||
'' => array(
|
||||
'base' => '',
|
||||
'class' => 'acp',
|
||||
'title' => 'ACP_EXTENSION_MANAGEMENT',
|
||||
'auth' => 'acl_a_extensions',
|
||||
'cat' => 'ACP_CAT_CUSTOMISE',
|
||||
),
|
||||
'extensions' => array(
|
||||
'base' => 'acp_extensions',
|
||||
'class' => 'acp',
|
||||
'title' => 'ACP_EXTENSIONS',
|
||||
'auth' => 'acl_a_extensions',
|
||||
'cat' => 'ACP_EXTENSION_MANAGEMENT',
|
||||
),
|
||||
);
|
||||
|
||||
_add_modules($modules_to_install);
|
||||
|
||||
// We need a separate array for the new language sub heading
|
||||
// because it requires another empty key
|
||||
$modules_to_install = array(
|
||||
'' => array(
|
||||
'base' => '',
|
||||
'class' => 'acp',
|
||||
'title' => 'ACP_LANGUAGE',
|
||||
'auth' => 'acl_a_language',
|
||||
'cat' => 'ACP_CAT_CUSTOMISE',
|
||||
),
|
||||
);
|
||||
|
||||
_add_modules($modules_to_install);
|
||||
|
||||
// Move language management to new location in the Customise tab
|
||||
// First get language module id
|
||||
$sql = 'SELECT module_id FROM ' . MODULES_TABLE . "
|
||||
WHERE module_basename = 'acp_language'";
|
||||
$result = $db->sql_query($sql);
|
||||
$language_module_id = $db->sql_fetchfield('module_id');
|
||||
$db->sql_freeresult($result);
|
||||
// Next get language management module id of the one just created
|
||||
$sql = 'SELECT module_id FROM ' . MODULES_TABLE . "
|
||||
WHERE module_langname = 'ACP_LANGUAGE'";
|
||||
$result = $db->sql_query($sql);
|
||||
$language_management_module_id = $db->sql_fetchfield('module_id');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!class_exists('acp_modules'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);
|
||||
}
|
||||
// acp_modules calls adm_back_link, which is undefined at this point
|
||||
if (!function_exists('adm_back_link'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_acp.' . $phpEx);
|
||||
}
|
||||
$module_manager = new acp_modules();
|
||||
$module_manager->module_class = 'acp';
|
||||
$module_manager->move_module($language_module_id, $language_management_module_id);
|
||||
|
||||
$sql = 'DELETE FROM ' . MODULES_TABLE . "
|
||||
WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')";
|
||||
_sql($sql, $errored, $error_ary);
|
||||
|
@ -2790,45 +2916,12 @@ function change_database_data(&$no_updates, $version)
|
|||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Add new permission u_chgprofileinfo and duplicate settings from u_sig
|
||||
// Add new permissions
|
||||
include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
|
||||
$auth_admin = new auth_admin();
|
||||
|
||||
// Only add the new permission if it does not already exist
|
||||
if (empty($auth_admin->acl_options['id']['u_chgprofileinfo']))
|
||||
{
|
||||
$auth_admin->acl_add_option(array('global' => array('u_chgprofileinfo')));
|
||||
|
||||
// Now the tricky part, filling the permission
|
||||
$old_id = $auth_admin->acl_options['id']['u_sig'];
|
||||
$new_id = $auth_admin->acl_options['id']['u_chgprofileinfo'];
|
||||
|
||||
$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);
|
||||
|
||||
foreach ($tables as $table)
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . $table . '
|
||||
WHERE auth_option_id = ' . $old_id;
|
||||
$result = _sql($sql, $errored, $error_ary);
|
||||
|
||||
$sql_ary = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$row['auth_option_id'] = $new_id;
|
||||
$sql_ary[] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (sizeof($sql_ary))
|
||||
{
|
||||
$db->sql_multi_insert($table, $sql_ary);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove any old permission entries
|
||||
$auth_admin->acl_clear_prefetch();
|
||||
}
|
||||
_add_permission($auth_admin, $db, 'u_chgprofileinfo', true, 'u_sig');
|
||||
_add_permission($auth_admin, $db, 'a_extensions', true, 'a_styles');
|
||||
|
||||
// Update the auth setting for the module
|
||||
$sql = 'UPDATE ' . MODULES_TABLE . "
|
||||
|
|
|
@ -215,7 +215,7 @@ $phpbb_style_path_provider = new phpbb_style_path_provider();
|
|||
$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, new phpbb_template_context());
|
||||
$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template);
|
||||
$phpbb_style->set_ext_dir_prefix('adm/');
|
||||
$phpbb_style->set_custom_style('admin', '../adm/style', '');
|
||||
$phpbb_style->set_custom_style('admin', '../adm/style', array(), '');
|
||||
$template->assign_var('T_ASSETS_PATH', '../assets');
|
||||
$template->assign_var('T_TEMPLATE_PATH', '../adm/style');
|
||||
|
||||
|
|
|
@ -121,10 +121,11 @@ class install_convert extends module
|
|||
|
||||
require($phpbb_root_path . 'config.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/constants.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions_convert.' . $phpEx);
|
||||
|
||||
$db = new $sql_db();
|
||||
$dbms = phpbb_convert_30_dbms_to_31($dbms);
|
||||
|
||||
$db = new $dbms();
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
|
||||
unset($dbpasswd);
|
||||
|
||||
|
@ -209,10 +210,11 @@ class install_convert extends module
|
|||
|
||||
require($phpbb_root_path . 'config.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/constants.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions_convert.' . $phpEx);
|
||||
|
||||
$db = new $sql_db();
|
||||
$dbms = phpbb_convert_30_dbms_to_31($dbms);
|
||||
|
||||
$db = new $dbms();
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
|
||||
unset($dbpasswd);
|
||||
|
||||
|
@ -332,10 +334,11 @@ class install_convert extends module
|
|||
|
||||
require($phpbb_root_path . 'config.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/constants.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions_convert.' . $phpEx);
|
||||
|
||||
$db = new $sql_db();
|
||||
$dbms = phpbb_convert_30_dbms_to_31($dbms);
|
||||
|
||||
$db = new $dbms();
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
|
||||
unset($dbpasswd);
|
||||
|
||||
|
@ -425,8 +428,7 @@ class install_convert extends module
|
|||
|
||||
if ($src_dbms != $dbms || $src_dbhost != $dbhost || $src_dbport != $dbport || $src_dbname != $dbname || $src_dbuser != $dbuser)
|
||||
{
|
||||
$sql_db = 'dbal_' . $src_dbms;
|
||||
$src_db = new $sql_db();
|
||||
$src_db = new $src_dbms();
|
||||
$src_db->sql_connect($src_dbhost, $src_dbuser, htmlspecialchars_decode($src_dbpasswd), $src_dbname, $src_dbport, false, true);
|
||||
$same_db = false;
|
||||
}
|
||||
|
@ -575,10 +577,11 @@ class install_convert extends module
|
|||
|
||||
require($phpbb_root_path . 'config.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/constants.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions_convert.' . $phpEx);
|
||||
|
||||
$db = new $sql_db();
|
||||
$dbms = phpbb_convert_30_dbms_to_31($dbms);
|
||||
|
||||
$db = new $dbms();
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
|
||||
unset($dbpasswd);
|
||||
|
||||
|
@ -639,12 +642,8 @@ class install_convert extends module
|
|||
$src_db = $same_db = null;
|
||||
if ($convert->src_dbms != $dbms || $convert->src_dbhost != $dbhost || $convert->src_dbport != $dbport || $convert->src_dbname != $dbname || $convert->src_dbuser != $dbuser)
|
||||
{
|
||||
if ($convert->src_dbms != $dbms)
|
||||
{
|
||||
require($phpbb_root_path . 'includes/db/' . $convert->src_dbms . '.' . $phpEx);
|
||||
}
|
||||
$sql_db = 'dbal_' . $convert->src_dbms;
|
||||
$src_db = new $sql_db();
|
||||
$dbms = $convert->src_dbms;
|
||||
$src_db = new $dbms();
|
||||
$src_db->sql_connect($convert->src_dbhost, $convert->src_dbuser, htmlspecialchars_decode($convert->src_dbpasswd), $convert->src_dbname, $convert->src_dbport, false, true);
|
||||
$same_db = false;
|
||||
}
|
||||
|
|
|
@ -1118,11 +1118,8 @@ class install_install extends module
|
|||
|
||||
$dbms = $available_dbms[$data['dbms']]['DRIVER'];
|
||||
|
||||
// Load the appropriate database class if not already loaded
|
||||
include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
||||
|
||||
// Instantiate the database
|
||||
$db = new $sql_db();
|
||||
$db = new $dbms();
|
||||
$db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);
|
||||
|
||||
// NOTE: trigger_error does not work here.
|
||||
|
@ -1418,11 +1415,8 @@ class install_install extends module
|
|||
|
||||
$dbms = $available_dbms[$data['dbms']]['DRIVER'];
|
||||
|
||||
// Load the appropriate database class if not already loaded
|
||||
include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
||||
|
||||
// Instantiate the database
|
||||
$db = new $sql_db();
|
||||
$db = new $dbms();
|
||||
$db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);
|
||||
|
||||
// NOTE: trigger_error does not work here.
|
||||
|
@ -2095,9 +2089,10 @@ class install_install extends module
|
|||
'ACP_PERMISSION_ROLES',
|
||||
'ACP_PERMISSION_MASKS',
|
||||
),
|
||||
'ACP_CAT_STYLES' => array(
|
||||
'ACP_CAT_CUSTOMISE' => array(
|
||||
'ACP_STYLE_MANAGEMENT',
|
||||
'ACP_STYLE_COMPONENTS',
|
||||
'ACP_EXTENSIONS_MANAGEMENT',
|
||||
'ACP_LANGUAGE',
|
||||
),
|
||||
'ACP_CAT_MAINTENANCE' => array(
|
||||
'ACP_FORUM_LOGS',
|
||||
|
|
|
@ -83,7 +83,6 @@ class install_update extends module
|
|||
|
||||
// Init DB
|
||||
require($phpbb_root_path . 'config.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/constants.' . $phpEx);
|
||||
|
||||
// Special options for conflicts/modified files
|
||||
|
@ -92,7 +91,9 @@ class install_update extends module
|
|||
define('MERGE_NEW_FILE', 3);
|
||||
define('MERGE_MOD_FILE', 4);
|
||||
|
||||
$db = new $sql_db();
|
||||
$dbms = phpbb_convert_30_dbms_to_31($dbms);
|
||||
|
||||
$db = new $dbms();
|
||||
|
||||
// Connect to DB
|
||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
|
||||
|
@ -131,7 +132,7 @@ class install_update extends module
|
|||
}
|
||||
|
||||
// Set custom template again. ;)
|
||||
$phpbb_style->set_custom_style('admin', '../adm/style', '');
|
||||
$phpbb_style->set_custom_style('admin', '../adm/style', array(), '');
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_USER_LANG' => $user->lang['USER_LANG'],
|
||||
|
|
|
@ -59,6 +59,7 @@ $lang = array_merge($lang, array(
|
|||
|
||||
'ACP_CAPTCHA' => 'CAPTCHA',
|
||||
|
||||
'ACP_CAT_CUSTOMISE' => 'Customise',
|
||||
'ACP_CAT_DATABASE' => 'Database',
|
||||
'ACP_CAT_DOT_MODS' => '.MODs',
|
||||
'ACP_CAT_FORUMS' => 'Forums',
|
||||
|
@ -80,8 +81,10 @@ $lang = array_merge($lang, array(
|
|||
'ACP_DISALLOW_USERNAMES' => 'Disallow usernames',
|
||||
|
||||
'ACP_EMAIL_SETTINGS' => 'Email settings',
|
||||
'ACP_EXTENSION_GROUPS' => 'Manage extension groups',
|
||||
'ACP_EXTENSIONS' => 'Manage board extensions',
|
||||
'ACP_EXTENSION_GROUPS' => 'Manage attachment extension groups',
|
||||
'ACP_EXTENSION_MANAGEMENT' => 'Extension management',
|
||||
'ACP_EXTENSIONS' => 'Extensions',
|
||||
|
||||
|
||||
'ACP_FORUM_BASED_PERMISSIONS' => 'Forum based permissions',
|
||||
'ACP_FORUM_LOGS' => 'Forum logs',
|
||||
|
@ -119,7 +122,7 @@ $lang = array_merge($lang, array(
|
|||
'ACP_MANAGE_ATTACHMENTS' => 'Manage attachments',
|
||||
'ACP_MANAGE_ATTACHMENTS_EXPLAIN' => 'Here you can list and delete files attached to posts and private messages.',
|
||||
|
||||
'ACP_MANAGE_EXTENSIONS' => 'Manage extensions',
|
||||
'ACP_MANAGE_EXTENSIONS' => 'Manage attachment extensions',
|
||||
'ACP_MANAGE_FORUMS' => 'Manage forums',
|
||||
'ACP_MANAGE_RANKS' => 'Manage ranks',
|
||||
'ACP_MANAGE_REASONS' => 'Manage report/denial reasons',
|
||||
|
@ -166,7 +169,6 @@ $lang = array_merge($lang, array(
|
|||
'ACP_SERVER_SETTINGS' => 'Server settings',
|
||||
'ACP_SIGNATURE_SETTINGS' => 'Signature settings',
|
||||
'ACP_SMILIES' => 'Smilies',
|
||||
'ACP_STYLE_COMPONENTS' => 'Style components',
|
||||
'ACP_STYLE_MANAGEMENT' => 'Style management',
|
||||
'ACP_STYLES' => 'Styles',
|
||||
'ACP_STYLES_CACHE' => 'Purge Cache',
|
||||
|
|
|
@ -186,6 +186,8 @@ $lang = array_merge($lang, array(
|
|||
'ERR_CONNECTING_SERVER' => 'Error connecting to the server.',
|
||||
'ERR_JAB_AUTH' => 'Could not authorise on Jabber server.',
|
||||
'ERR_JAB_CONNECT' => 'Could not connect to Jabber server.',
|
||||
'ERR_TEMPLATE_EVENT_LOCATION' => 'The specified template event location <em>[%s]</em> is improperly formatted.',
|
||||
'ERR_TEMPLATE_COMPILATION' => 'The file could not be compiled: %s',
|
||||
'ERR_UNABLE_TO_LOGIN' => 'The specified username or password is incorrect.',
|
||||
'ERR_UNWATCHING' => 'An error occured while trying to unsubscribe.',
|
||||
'ERR_WATCHING' => 'An error occured while trying to subscribe.',
|
||||
|
|
|
@ -10,13 +10,14 @@
|
|||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF S_DISPLAY_JUMPBOX -->
|
||||
<form method="post" id="jumpbox" action="{S_JUMPBOX_ACTION}" onsubmit="if(this.f.value == -1){return false;}">
|
||||
<form method="get" id="jumpbox" action="{S_JUMPBOX_ACTION}" onsubmit="if(this.f.value == -1){return false;}">
|
||||
|
||||
<!-- IF $CUSTOM_FIELDSET_CLASS -->
|
||||
<fieldset class="{$CUSTOM_FIELDSET_CLASS}">
|
||||
<!-- ELSE -->
|
||||
<fieldset class="jumpbox">
|
||||
<!-- ENDIF -->
|
||||
{HIDDEN_FIELDS_FOR_JUMPBOX}
|
||||
<label for="f" accesskey="j"><!-- IF S_IN_MCP and S_MERGE_SELECT -->{L_SELECT_TOPICS_FROM}<!-- ELSEIF S_IN_MCP -->{L_MODERATE_FORUM}<!-- ELSE -->{L_JUMP_TO}<!-- ENDIF -->{L_COLON}</label>
|
||||
<select name="f" id="f" onchange="if(this.options[this.selectedIndex].value != -1){ document.forms['jumpbox'].submit() }">
|
||||
<!-- BEGIN jumpbox_forums -->
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
<!-- IF S_DISPLAY_JUMPBOX -->
|
||||
<form method="post" name="jumpbox" action="{S_JUMPBOX_ACTION}" onsubmit="if(document.jumpbox.f.value == -1){return false;}">
|
||||
<form method="get" name="jumpbox" action="{S_JUMPBOX_ACTION}" onsubmit="if(document.jumpbox.f.value == -1){return false;}">
|
||||
|
||||
<table cellspacing="0" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td nowrap="nowrap"><span class="gensmall"><!-- IF S_IN_MCP and S_MERGE_SELECT -->{L_SELECT_TOPICS_FROM}<!-- ELSEIF S_IN_MCP -->{L_MODERATE_FORUM}<!-- ELSE -->{L_JUMP_TO}<!-- ENDIF -->{L_COLON}</span> <select name="f" onchange="if(this.options[this.selectedIndex].value != -1){ document.forms['jumpbox'].submit() }">
|
||||
<td nowrap="nowrap">{HIDDEN_FIELDS_FOR_JUMPBOX}<span class="gensmall"><!-- IF S_IN_MCP and S_MERGE_SELECT -->{L_SELECT_TOPICS_FROM}<!-- ELSEIF S_IN_MCP -->{L_MODERATE_FORUM}<!-- ELSE -->{L_JUMP_TO}<!-- ENDIF -->{L_COLON}</span> <select name="f" onchange="if(this.options[this.selectedIndex].value != -1){ document.forms['jumpbox'].submit() }">
|
||||
|
||||
<!-- BEGIN jumpbox_forums -->
|
||||
<!-- IF jumpbox_forums.S_FORUM_COUNT eq 1 --><option value="-1">------------------</option><!-- ENDIF -->
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<!-- Note: no longer in use... -->
|
||||
|
||||
<form name="jumpbox" method="post" action="{S_JUMPBOX_ACTION}">
|
||||
<form name="jumpbox" method="get" action="{S_JUMPBOX_ACTION}">
|
||||
|
||||
{HIDDEN_FIELDS_FOR_JUMPBOX}
|
||||
<span class="gensmall">{L_JUMP_TO}{L_COLON}</span> <select name="f" onChange="if(this.options[this.selectedIndex].value != -1 && this.options[this.selectedIndex].value != document.jumpbox.current_f.value){ document.forms['jumpbox'].submit() }">
|
||||
|
||||
<!-- IF S_ENABLE_SELECT_ALL -->
|
||||
|
|
|
@ -1353,7 +1353,7 @@ if (sizeof($attach_list))
|
|||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_HAS_ATTACHMENTS' => !empty($attachments),
|
||||
'S_HAS_ATTACHMENTS' => $topic_data['topic_attachment'],
|
||||
));
|
||||
|
||||
$methods = phpbb_gen_download_links('topic_id', $topic_id, $phpbb_root_path, $phpEx);
|
||||
|
|
|
@ -30,7 +30,7 @@ example for mysqli can be found below. More information on configuration
|
|||
options can be found on the wiki (see below).
|
||||
|
||||
<?php
|
||||
$dbms = 'mysqli';
|
||||
$dbms = 'phpbb_db_driver_mysqli';
|
||||
$dbhost = 'localhost';
|
||||
$dbport = '';
|
||||
$dbname = 'database';
|
||||
|
|
41
tests/dbal/connect_test.php
Normal file
41
tests/dbal/connect_test.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_dbal_connect_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml');
|
||||
}
|
||||
|
||||
public function test_failing_connect()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$config = $this->get_database_config();
|
||||
|
||||
$db = new $config['dbms']();
|
||||
|
||||
// Failure to connect results in a trigger_error call in dbal.
|
||||
// phpunit converts triggered errors to exceptions.
|
||||
// In particular there should be no fatals here.
|
||||
try
|
||||
{
|
||||
$db->sql_connect($config['dbhost'], 'phpbbogus', 'phpbbogus', 'phpbbogus', $config['dbport']);
|
||||
$this->assertFalse(true);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
// should have a legitimate message
|
||||
$this->assertNotEmpty($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,6 +33,10 @@ class phpbb_dbal_write_sequence_test extends phpbb_database_test_case
|
|||
{
|
||||
$db = $this->new_dbal();
|
||||
|
||||
// dbal uses cache
|
||||
global $cache;
|
||||
$cache = new phpbb_mock_cache();
|
||||
|
||||
$sql = 'INSERT INTO phpbb_users ' . $db->sql_build_array('INSERT', array(
|
||||
'username' => $username,
|
||||
'username_clean' => $username,
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_container.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/db/dbal.php';
|
||||
|
||||
class phpbb_di_container_test extends phpbb_test_case
|
||||
{
|
||||
|
@ -52,7 +51,7 @@ class phpbb_di_container_test extends phpbb_test_case
|
|||
}
|
||||
}
|
||||
|
||||
class dbal_container_mock extends dbal
|
||||
class phpbb_db_driver_container_mock extends phpbb_db_driver
|
||||
{
|
||||
public function sql_connect()
|
||||
{
|
||||
|
|
6
tests/fixtures/empty.xml
vendored
6
tests/fixtures/empty.xml
vendored
|
@ -1,5 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_posts">
|
||||
<table name="phpbb_sessions">
|
||||
<column>session_id</column>
|
||||
<column>session_user_id</column>
|
||||
<column>session_ip</column>
|
||||
<column>session_browser</column>
|
||||
</table>
|
||||
</dataset>
|
||||
|
|
|
@ -18,9 +18,19 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
|
|||
|
||||
// check for logout link
|
||||
$crawler = $this->request('GET', 'index.php');
|
||||
$this->assert_response_success();
|
||||
$this->assertContains($this->lang('LOGOUT_USER', 'admin'), $crawler->filter('.navbar')->text());
|
||||
}
|
||||
|
||||
public function test_login_other()
|
||||
{
|
||||
$this->create_user('anothertestuser');
|
||||
$this->login('anothertestuser');
|
||||
$crawler = $this->request('GET', 'index.php');
|
||||
$this->assert_response_success();
|
||||
$this->assertContains('anothertestuser', $crawler->filter('.icon-logout')->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends test_login
|
||||
*/
|
||||
|
@ -31,10 +41,12 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
|
|||
|
||||
// logout
|
||||
$crawler = $this->request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
|
||||
$this->assert_response_success();
|
||||
$this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text());
|
||||
|
||||
// look for a register link, which should be visible only when logged out
|
||||
$crawler = $this->request('GET', 'index.php');
|
||||
$this->assert_response_success();
|
||||
$this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text());
|
||||
}
|
||||
}
|
||||
|
|
43
tests/functional/memberlist_test.php
Normal file
43
tests/functional/memberlist_test.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?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_memberlist_test extends phpbb_functional_test_case
|
||||
{
|
||||
public function test_memberlist()
|
||||
{
|
||||
$this->create_user('memberlist-test-user');
|
||||
// logs in as admin
|
||||
$this->login();
|
||||
$crawler = $this->request('GET', 'memberlist.php?sid=' . $this->sid);
|
||||
$this->assert_response_success();
|
||||
$this->assertContains('memberlist-test-user', $crawler->text());
|
||||
|
||||
// restrict by first character
|
||||
$crawler = $this->request('GET', 'memberlist.php?first_char=m&sid=' . $this->sid);
|
||||
$this->assert_response_success();
|
||||
$this->assertContains('memberlist-test-user', $crawler->text());
|
||||
|
||||
// make sure results for wrong character are not returned
|
||||
$crawler = $this->request('GET', 'memberlist.php?first_char=a&sid=' . $this->sid);
|
||||
$this->assert_response_success();
|
||||
$this->assertNotContains('memberlist-test-user', $crawler->text());
|
||||
}
|
||||
|
||||
public function test_viewprofile()
|
||||
{
|
||||
$this->login();
|
||||
// XXX hardcoded user id
|
||||
$crawler = $this->request('GET', 'memberlist.php?mode=viewprofile&u=2&sid=' . $this->sid);
|
||||
$this->assert_response_success();
|
||||
$this->assertContains('admin', $crawler->filter('h2')->text());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_build_hidden_fields_for_query_params_test extends phpbb_test_case
|
||||
{
|
||||
public function build_hidden_fields_for_query_params_test_data()
|
||||
{
|
||||
return array(
|
||||
// get
|
||||
// post
|
||||
// exclude
|
||||
// expected
|
||||
array(
|
||||
array('foo' => 'bar'),
|
||||
array(),
|
||||
array(),
|
||||
"<input type='hidden' name=\"foo\" value=\"bar\" />",
|
||||
),
|
||||
array(
|
||||
array('foo' => 'bar', 'a' => 'b'),
|
||||
array(),
|
||||
array(),
|
||||
"<input type='hidden' name=\"foo\" value=\"bar\" /><input type='hidden' name=\"a\" value=\"b\" />",
|
||||
),
|
||||
array(
|
||||
array('a' => 'quote"', 'b' => '<less>'),
|
||||
array(),
|
||||
array(),
|
||||
"<input type='hidden' name=\"a\" value='quote\"' /><input type='hidden' name=\"b\" value=\"<less>\" />",
|
||||
),
|
||||
array(
|
||||
array('a' => "quotes'\""),
|
||||
array(),
|
||||
array(),
|
||||
"<input type='hidden' name=\"a\" value=\"quotes'"\" />",
|
||||
),
|
||||
array(
|
||||
array('foo' => 'bar', 'a' => 'b'),
|
||||
array('a' => 'c'),
|
||||
array(),
|
||||
"<input type='hidden' name=\"foo\" value=\"bar\" />",
|
||||
),
|
||||
// strict equality check
|
||||
array(
|
||||
array('foo' => 'bar', 'a' => '0'),
|
||||
array('a' => ''),
|
||||
array(),
|
||||
"<input type='hidden' name=\"foo\" value=\"bar\" />",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider build_hidden_fields_for_query_params_test_data
|
||||
*/
|
||||
public function test_build_hidden_fields_for_query_params($get, $post, $exclude, $expected)
|
||||
{
|
||||
$request = new phpbb_mock_request($get, $post);
|
||||
$result = phpbb_build_hidden_fields_for_query_params($request, $exclude);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
40
tests/functions/convert_30_dbms_to_31_test.php
Normal file
40
tests/functions/convert_30_dbms_to_31_test.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case
|
||||
{
|
||||
public function convert_30_dbms_to_31_data()
|
||||
{
|
||||
return array(
|
||||
array('firebird'),
|
||||
array('mssql'),
|
||||
array('mssql_odbc'),
|
||||
array('mssqlnative'),
|
||||
array('mysql'),
|
||||
array('mysqli'),
|
||||
array('oracle'),
|
||||
array('postgres'),
|
||||
array('sqlite'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider convert_30_dbms_to_31_data
|
||||
*/
|
||||
public function test_convert_30_dbms_to_31($input)
|
||||
{
|
||||
$expected = "phpbb_db_driver_$input";
|
||||
|
||||
$output = phpbb_convert_30_dbms_to_31($input);
|
||||
|
||||
$this->assertEquals($expected, $output);
|
||||
}
|
||||
}
|
44
tests/functions/quoteattr_test.php
Normal file
44
tests/functions/quoteattr_test.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_quoteattr_test extends phpbb_test_case
|
||||
{
|
||||
public function quoteattr_test_data()
|
||||
{
|
||||
return array(
|
||||
array('foo', null, '"foo"'),
|
||||
array('', null, '""'),
|
||||
array(' ', null, '" "'),
|
||||
array('<a>', null, '"<a>"'),
|
||||
array('&', null, '"&amp;"'),
|
||||
array('"hello"', null, "'\"hello\"'"),
|
||||
array("'hello'", null, "\"'hello'\""),
|
||||
array("\"'", null, "\""'\""),
|
||||
array("a\nb", null, '"a b"'),
|
||||
array("a\r\nb", null, '"a b"'),
|
||||
array("a\tb", null, '"a	b"'),
|
||||
array('a b', null, '"a b"'),
|
||||
array('"a<b"', null, "'\"a<b\"'"),
|
||||
array('foo', array('f' => 'z'), '"zoo"'),
|
||||
array('<a>', array('a' => '&'), '"<&>"'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider quoteattr_test_data
|
||||
*/
|
||||
public function test_quoteattr($input, $entities, $expected)
|
||||
{
|
||||
$output = phpbb_quoteattr($input, $entities);
|
||||
|
||||
$this->assertEquals($expected, $output);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_bookmarks">
|
||||
<column>user_id</column>
|
||||
<column>topic_id</column>
|
||||
|
||||
<!-- one entry for this topic -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
|
||||
<!-- non-conflicting entries -->
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>3</value>
|
||||
</row>
|
||||
|
||||
<!-- conflicting entries -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>4</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>5</value>
|
||||
</row>
|
||||
|
||||
<!-- conflicting and non-conflicting entries -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>6</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>7</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>6</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_topics_watch">
|
||||
<column>user_id</column>
|
||||
<column>topic_id</column>
|
||||
<column>notify_status</column>
|
||||
|
||||
<!-- one entry for this topic -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
|
||||
<!-- non-conflicting entries -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>3</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
|
||||
<!-- conflicting entries, same notify status -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>4</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>5</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
|
||||
<!-- conflicting entries, notify status 0 into 1 -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>6</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>7</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
|
||||
<!-- conflicting entries, notify status 1 into 0 -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>8</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>9</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
|
||||
<!-- conflicting and non-conflicting entries -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>10</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>11</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>10</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_database_helper.php';
|
||||
|
||||
class phpbb_update_rows_avoiding_duplicates_notify_status_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/topics_watch_duplicates.xml');
|
||||
}
|
||||
|
||||
public static function fixture_data()
|
||||
{
|
||||
return array(
|
||||
// description
|
||||
// from array
|
||||
// to value
|
||||
// expected count with to value post update
|
||||
// expected notify_status values
|
||||
array(
|
||||
'trivial',
|
||||
array(1),
|
||||
1000,
|
||||
1,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
'no conflict',
|
||||
array(2),
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
'conflict, same notify status',
|
||||
array(4),
|
||||
5,
|
||||
1,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
'conflict, notify status 0 into 1',
|
||||
array(6),
|
||||
7,
|
||||
1,
|
||||
0,
|
||||
),
|
||||
array(
|
||||
'conflict, notify status 1 into 0',
|
||||
array(8),
|
||||
9,
|
||||
1,
|
||||
0,
|
||||
),
|
||||
array(
|
||||
'conflict and no conflict',
|
||||
array(10),
|
||||
11,
|
||||
2,
|
||||
0,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider fixture_data
|
||||
*/
|
||||
public function test_update($description, $from, $to, $expected_result_count, $expected_notify_status)
|
||||
{
|
||||
$db = $this->new_dbal();
|
||||
|
||||
phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $from, $to);
|
||||
|
||||
$sql = 'SELECT COUNT(*) AS remaining_rows
|
||||
FROM ' . TOPICS_WATCH_TABLE . '
|
||||
WHERE topic_id = ' . (int) $to;
|
||||
$result = $db->sql_query($sql);
|
||||
$result_count = $db->sql_fetchfield('remaining_rows');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->assertEquals($expected_result_count, $result_count);
|
||||
|
||||
// user id of 1 is the user being updated
|
||||
$sql = 'SELECT notify_status
|
||||
FROM ' . TOPICS_WATCH_TABLE . '
|
||||
WHERE topic_id = ' . (int) $to . '
|
||||
AND user_id = 1';
|
||||
$result = $db->sql_query($sql);
|
||||
$notify_status = $db->sql_fetchfield('notify_status');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->assertEquals($expected_notify_status, $notify_status);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_database_helper.php';
|
||||
|
||||
class phpbb_update_rows_avoiding_duplicates_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/bookmarks_duplicates.xml');
|
||||
}
|
||||
|
||||
public static function fixture_data()
|
||||
{
|
||||
return array(
|
||||
// description
|
||||
// from array
|
||||
// to value
|
||||
// expected count with to value post update
|
||||
array(
|
||||
'trivial',
|
||||
array(1),
|
||||
10,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
'no conflict',
|
||||
array(2),
|
||||
3,
|
||||
2,
|
||||
),
|
||||
array(
|
||||
'conflict',
|
||||
array(4),
|
||||
5,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
'conflict and no conflict',
|
||||
array(6),
|
||||
7,
|
||||
2,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider fixture_data
|
||||
*/
|
||||
public function test_update($description, $from, $to, $expected_result_count)
|
||||
{
|
||||
$db = $this->new_dbal();
|
||||
|
||||
phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $from, $to);
|
||||
|
||||
$sql = 'SELECT COUNT(*) AS remaining_rows
|
||||
FROM ' . BOOKMARKS_TABLE . '
|
||||
WHERE topic_id = ' . (int) $to;
|
||||
$result = $db->sql_query($sql);
|
||||
$result_count = $db->sql_fetchfield('remaining_rows');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->assertEquals($expected_result_count, $result_count);
|
||||
}
|
||||
}
|
32
tests/mock/filesystem_extension_manager.php
Normal file
32
tests/mock/filesystem_extension_manager.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_mock_filesystem_extension_manager extends phpbb_mock_extension_manager
|
||||
{
|
||||
public function __construct($phpbb_root_path)
|
||||
{
|
||||
$extensions = array();
|
||||
$iterator = new DirectoryIterator($phpbb_root_path . 'ext/');
|
||||
foreach ($iterator as $fileinfo)
|
||||
{
|
||||
if ($fileinfo->isDir() && substr($fileinfo->getFilename(), 0, 1) != '.')
|
||||
{
|
||||
$name = $fileinfo->getFilename();
|
||||
$extension = array(
|
||||
'ext_name' => $name,
|
||||
'ext_active' => true,
|
||||
'ext_path' => 'ext/' . $name . '/',
|
||||
);
|
||||
$extensions[$name] = $extension;
|
||||
}
|
||||
}
|
||||
ksort($extensions);
|
||||
parent::__construct($phpbb_root_path, $extensions);
|
||||
}
|
||||
}
|
47
tests/mock/null_cache.php
Normal file
47
tests/mock/null_cache.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_mock_null_cache
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function get($var_name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function put($var_name, $var, $ttl = 0)
|
||||
{
|
||||
}
|
||||
|
||||
public function destroy($var_name, $table = '')
|
||||
{
|
||||
}
|
||||
|
||||
public function obtain_bots()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function obtain_word_list()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function set_bots($bots)
|
||||
{
|
||||
}
|
||||
|
||||
public function sql_exists($query_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ class phpbb_search_mysql_test extends phpbb_search_common_test_case
|
|||
parent::setUp();
|
||||
|
||||
// dbal uses cache
|
||||
$cache = new phpbb_cache_service(new phpbb_cache_driver_null);
|
||||
$cache = new phpbb_mock_cache();
|
||||
|
||||
// set config values
|
||||
$config['fulltext_mysql_min_word_len'] = 4;
|
||||
|
|
|
@ -26,7 +26,7 @@ class phpbb_search_native_test extends phpbb_search_test_case
|
|||
parent::setUp();
|
||||
|
||||
// dbal uses cache
|
||||
$cache = new phpbb_cache_service(new phpbb_cache_driver_null);
|
||||
$cache = new phpbb_mock_cache();
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$error = null;
|
||||
|
|
|
@ -26,7 +26,7 @@ class phpbb_search_postgres_test extends phpbb_search_common_test_case
|
|||
parent::setUp();
|
||||
|
||||
// dbal uses cache
|
||||
$cache = new phpbb_cache_service(new phpbb_cache_driver_null);
|
||||
$cache = new phpbb_mock_cache();
|
||||
|
||||
// set config values
|
||||
$config['fulltext_postgres_min_word_len'] = 4;
|
||||
|
|
|
@ -59,10 +59,10 @@ class phpbb_session_testable_factory
|
|||
/**
|
||||
* Retrieve the configured session class instance
|
||||
*
|
||||
* @param dbal $dbal The database connection to use for session data
|
||||
* @param phpbb_db_driver $dbal The database connection to use for session data
|
||||
* @return phpbb_mock_session_testable A session instance
|
||||
*/
|
||||
public function get_session(dbal $dbal)
|
||||
public function get_session(phpbb_db_driver $dbal)
|
||||
{
|
||||
// set up all the global variables used by session
|
||||
global $SID, $_SID, $db, $config, $cache, $request;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Kappa test event in all
|
|
@ -0,0 +1 @@
|
|||
Kappa test event in silver
|
|
@ -0,0 +1 @@
|
|||
Kappa test event in silver_inherit
|
|
@ -0,0 +1 @@
|
|||
Omega test event in all
|
|
@ -0,0 +1 @@
|
|||
Omega test event in silver
|
|
@ -0,0 +1 @@
|
|||
two in silver in omega
|
|
@ -0,0 +1 @@
|
|||
Zeta test event in all
|
|
@ -0,0 +1 @@
|
|||
<!-- EVENT test -->
|
|
@ -0,0 +1 @@
|
|||
<!-- EVENT two -->
|
|
@ -0,0 +1 @@
|
|||
<!-- EVENT test -->
|
|
@ -0,0 +1 @@
|
|||
Universal in trivial extension.
|
|
@ -0,0 +1 @@
|
|||
Simple in trivial extension.
|
|
@ -0,0 +1 @@
|
|||
<!-- EVENT simple -->
|
|
@ -0,0 +1 @@
|
|||
<!-- EVENT universal -->
|
|
@ -48,7 +48,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
|
|||
|
||||
$this->setup_engine(array('tpl_allow_php' => true));
|
||||
|
||||
$this->style->set_custom_style('tests', $cache_dir, '');
|
||||
$this->style->set_custom_style('tests', $cache_dir, array(), '');
|
||||
$cache_file = $this->template->cachepath . 'includephp_absolute.html.php';
|
||||
|
||||
$this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php", $cache_file);
|
||||
|
|
|
@ -16,7 +16,7 @@ class phpbb_template_template_compile_test extends phpbb_test_case
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->template_compile = new phpbb_template_compile(false, null, '');
|
||||
$this->template_compile = new phpbb_template_compile(false, null, $this->style_resource_locator, '');
|
||||
$this->template_path = dirname(__FILE__) . '/templates';
|
||||
}
|
||||
|
||||
|
|
118
tests/template/template_events_test.php
Normal file
118
tests/template/template_events_test.php
Normal file
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/template_test_case.php';
|
||||
|
||||
class phpbb_template_template_events_test extends phpbb_template_template_test_case
|
||||
{
|
||||
public function template_data()
|
||||
{
|
||||
return array(
|
||||
/*
|
||||
array(
|
||||
'', // file
|
||||
'', // dataset
|
||||
array(), // style names
|
||||
array(), // vars
|
||||
array(), // block vars
|
||||
array(), // destroy
|
||||
'', // expected result
|
||||
),
|
||||
*/
|
||||
array(
|
||||
'Simple template event',
|
||||
'ext_trivial',
|
||||
array(),
|
||||
'event_simple.html',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
"Simple in trivial extension.",
|
||||
),
|
||||
array(
|
||||
'Universal template event ("all" style)',
|
||||
'ext_trivial',
|
||||
array(),
|
||||
'event_universal.html',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
"Universal in trivial extension.",
|
||||
),
|
||||
array(
|
||||
'Template event with inheritance - parent',
|
||||
'event_inheritance',
|
||||
array('silver'),
|
||||
'event_test.html',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'Kappa test event in all
|
||||
Omega test event in all
|
||||
Zeta test event in all
|
||||
Kappa test event in silver
|
||||
Omega test event in silver',
|
||||
),
|
||||
array(
|
||||
'Template event with inheritance - child',
|
||||
'event_inheritance',
|
||||
array('silver_inherit', 'silver'),
|
||||
'event_test.html',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'Kappa test event in all
|
||||
Omega test event in all
|
||||
Zeta test event in all
|
||||
Kappa test event in silver_inherit',
|
||||
),
|
||||
array(
|
||||
'Definition in parent style',
|
||||
'event_inheritance',
|
||||
array('silver_inherit', 'silver'),
|
||||
'event_two.html',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'two in silver in omega',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider template_data
|
||||
*/
|
||||
public function test_event($desc, $dataset, $style_names, $file, array $vars, array $block_vars, array $destroy, $expected)
|
||||
{
|
||||
// Reset the engine state
|
||||
$this->setup_engine_for_events($dataset, $style_names);
|
||||
|
||||
// Run test
|
||||
$cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
|
||||
$this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
|
||||
}
|
||||
|
||||
protected function setup_engine_for_events($dataset, $style_names, array $new_config = array())
|
||||
{
|
||||
global $phpbb_root_path, $phpEx, $user;
|
||||
|
||||
$defaults = $this->config_defaults();
|
||||
$config = new phpbb_config(array_merge($defaults, $new_config));
|
||||
|
||||
$this->template_path = dirname(__FILE__) . "/datasets/$dataset/styles/silver/template";
|
||||
$this->style_resource_locator = new phpbb_style_resource_locator();
|
||||
$this->extension_manager = new phpbb_mock_filesystem_extension_manager(
|
||||
dirname(__FILE__) . "/datasets/$dataset/"
|
||||
);
|
||||
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context, $this->extension_manager);
|
||||
$this->style_provider = new phpbb_style_path_provider();
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
|
||||
$this->style->set_custom_style('silver', array($this->template_path), $style_names, '');
|
||||
}
|
||||
}
|
|
@ -69,7 +69,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
|||
$this->style_provider = new phpbb_style_path_provider();
|
||||
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context());
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
|
||||
$this->style->set_custom_style('tests', $this->template_path, '');
|
||||
$this->style->set_custom_style('tests', $this->template_path, array(), '');
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
|
|
|
@ -24,6 +24,6 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
|
|||
$this->style_provider = new phpbb_style_path_provider();
|
||||
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context());
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
|
||||
$this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), '');
|
||||
$this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), array(), '');
|
||||
}
|
||||
}
|
||||
|
|
4
tests/template/templates/events.html
Normal file
4
tests/template/templates/events.html
Normal file
|
@ -0,0 +1,4 @@
|
|||
<!-- EVENT child_only -->
|
||||
<!-- EVENT parent_only -->
|
||||
<!-- EVENT parent_and_child -->
|
||||
<!-- EVENT random_event -->
|
|
@ -49,7 +49,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
|||
$db_config = $this->get_database_config();
|
||||
|
||||
// Firebird requires table and column names to be uppercase
|
||||
if ($db_config['dbms'] == 'firebird')
|
||||
if ($db_config['dbms'] == 'phpbb_db_driver_firebird')
|
||||
{
|
||||
$xml_data = file_get_contents($path);
|
||||
$xml_data = preg_replace_callback('/(?:(<table name="))([a-z_]+)(?:(">))/', 'phpbb_database_test_case::to_upper', $xml_data);
|
||||
|
@ -118,9 +118,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
|||
|
||||
$config = $this->get_database_config();
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/db/' . $config['dbms'] . '.php';
|
||||
$dbal = 'dbal_' . $config['dbms'];
|
||||
$db = new $dbal();
|
||||
$db = new $config['dbms']();
|
||||
$db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport']);
|
||||
|
||||
return $db;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue