[ticket/11015] Make DBAL classes autoloadable

PHPBB3-11015

This allows us to just create the object without having to include the
driver first. However, it also means that users must specify the full
class name in config.php
This commit is contained in:
Igor Wiedler 2012-07-21 17:43:43 +02:00
parent f7f78adeb9
commit 90a957ad26
26 changed files with 1129 additions and 1189 deletions

View file

@ -79,7 +79,6 @@ require($phpbb_root_path . 'includes/functions.' . $phpEx);
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
// Set PHP error handler to ours
@ -102,7 +101,7 @@ $phpbb_dispatcher = new phpbb_event_dispatcher();
$request = new phpbb_request();
$user = new phpbb_user();
$auth = new phpbb_auth();
$db = new $sql_db();
$db = new $dbms();
// make sure request_var uses this request instance
request_var('', 0, false, false, $request); // "dependency injection" for a function

View file

@ -39,7 +39,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_download' . '.' . $phpEx);
@ -58,7 +57,7 @@ if (isset($_GET['avatar']))
$phpbb_dispatcher = new phpbb_event_dispatcher();
$request = new phpbb_request();
$db = new $sql_db();
$db = new $dbms();
// Connect to DB
if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false))

View file

@ -46,7 +46,7 @@ class phpbb_config_db extends phpbb_config
* @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;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -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;

View file

@ -15,14 +15,12 @@ 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
{
/**
* Connect to server
@ -374,7 +372,7 @@ class dbal_mssql extends dbal
FROM master.dbo.sysmessages
WHERE error = ' . $error['code'];
$result_id = @mssql_query($sql);
if ($result_id)
{
$row = @mssql_fetch_assoc($result_id);

View file

@ -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,7 +26,7 @@ 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 = '';

View file

@ -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,7 +191,7 @@ 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 = '';

View file

@ -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,7 +24,7 @@ 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;

View file

@ -15,15 +15,13 @@ 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;

View file

@ -15,13 +15,11 @@ 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 = '';

View file

@ -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 = '';

View file

@ -15,14 +15,12 @@ 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
{
/**
* Connect to server

View file

@ -39,7 +39,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, $extension_table, $phpbb_root_path, $phpEx = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext')
public function __construct(phpbb_db_driver $db, $extension_table, $phpbb_root_path, $phpEx = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext')
{
$this->phpbb_root_path = $phpbb_root_path;
$this->db = $db;
@ -432,7 +432,7 @@ class phpbb_extension_manager
}
return $disabled;
}
/**
* Check to see if a given extension is available on the filesystem
*

View file

@ -49,7 +49,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,
),
@ -58,7 +58,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,
),
@ -67,7 +67,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,
),
@ -76,7 +76,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,
),
@ -85,7 +85,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,
),
@ -94,7 +94,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,
),
@ -103,7 +103,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,
),
@ -112,7 +112,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,
),
@ -121,7 +121,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,
),
@ -229,26 +229,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;
@ -257,8 +250,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'];
@ -267,22 +260,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;
}
@ -320,21 +313,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'))
{
@ -415,7 +408,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 *
@ -437,7 +430,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;";

View file

@ -91,7 +91,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);
@ -121,7 +120,7 @@ $phpbb_class_loader->set_cache($cache->get_driver());
$phpbb_dispatcher = new phpbb_event_dispatcher();
$request = new phpbb_request();
$user = new phpbb_user();
$db = new $sql_db();
$db = new $dbms();
// make sure request_var uses this request instance
request_var('', 0, false, false, $request); // "dependency injection" for a function
@ -2601,10 +2600,10 @@ function change_database_data(&$no_updates, $version)
// Create config value for displaying last subject on forum list
if (!isset($config['display_last_subject']))
{
{
$config->set('display_last_subject', '1');
}
$no_updates = false;
if (!isset($config['assets_version']))

View file

@ -121,10 +121,9 @@ 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();
$db = new $dbms();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
unset($dbpasswd);
@ -209,10 +208,8 @@ 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();
$db = new $dbms();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
unset($dbpasswd);
@ -332,10 +329,9 @@ 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();
$db = new $dbms();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
unset($dbpasswd);
@ -425,8 +421,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 +570,9 @@ 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();
$db = new $dbms();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
unset($dbpasswd);
@ -639,12 +633,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;
}

View file

@ -250,7 +250,7 @@ class install_install extends module
'S_EXPLAIN' => true,
'S_LEGEND' => false,
));
// Check for php json support
if (@extension_loaded('json'))
{
@ -1144,11 +1144,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.
@ -1444,11 +1441,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.

View file

@ -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,7 @@ class install_update extends module
define('MERGE_NEW_FILE', 3);
define('MERGE_MOD_FILE', 4);
$db = new $sql_db();
$db = new $dbms();
// Connect to DB
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);

View file

@ -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';

View file

@ -62,7 +62,7 @@ class phpbb_session_testable_factory
* @param dbal $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;

View file

@ -33,7 +33,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);
@ -100,9 +100,8 @@ 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();
$dbms = $config['dbms'];
$db = new $dbms();
$db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport']);
return $db;

View file

@ -108,7 +108,7 @@ class phpbb_database_test_connection_manager
// These require different connection strings on the phpBB side than they do in PDO
// so you must provide a DSN string for ODBC separately
if (!empty($this->config['custom_dsn']) && ($this->config['dbms'] == 'mssql' || $this->config['dbms'] == 'firebird'))
if (!empty($this->config['custom_dsn']) && ($this->config['dbms'] == 'phpbb_db_driver_mssql' || $this->config['dbms'] == 'phpbb_db_driver_firebird'))
{
$dsn = 'odbc:' . $this->config['custom_dsn'];
}
@ -117,12 +117,12 @@ class phpbb_database_test_connection_manager
{
switch ($this->config['dbms'])
{
case 'mssql':
case 'mssql_odbc':
case 'phpbb_db_driver_mssql':
case 'phpbb_db_driver_mssql_odbc':
$this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('mssql', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']);
break;
case 'firebird':
case 'phpbb_db_driver_firebird':
if (!empty($this->config['custom_dsn']))
{
$this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('firebird', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']);
@ -165,14 +165,14 @@ class phpbb_database_test_connection_manager
{
switch ($this->config['dbms'])
{
case 'sqlite':
case 'phpbb_db_driver_sqlite':
if (file_exists($this->config['dbhost']))
{
unlink($this->config['dbhost']);
}
break;
case 'firebird':
case 'phpbb_db_driver_firebird':
$this->connect();
// Drop all of the tables
foreach ($this->get_tables() as $table)
@ -182,7 +182,7 @@ class phpbb_database_test_connection_manager
$this->purge_extras();
break;
case 'oracle':
case 'phpbb_db_driver_oracle':
$this->connect();
// Drop all of the tables
foreach ($this->get_tables() as $table)
@ -232,39 +232,39 @@ class phpbb_database_test_connection_manager
switch ($this->config['dbms'])
{
case 'mysql':
case 'mysql4':
case 'mysqli':
case 'phpbb_db_driver_mysql':
case 'phpbb_db_driver_mysql4':
case 'phpbb_db_driver_mysqli':
$sql = 'SHOW TABLES';
break;
case 'sqlite':
case 'phpbb_db_driver_sqlite':
$sql = 'SELECT name
FROM sqlite_master
WHERE type = "table"';
break;
case 'mssql':
case 'mssql_odbc':
case 'mssqlnative':
case 'phpbb_db_driver_mssql':
case 'phpbb_db_driver_mssql_odbc':
case 'phpbb_db_driver_mssqlnative':
$sql = "SELECT name
FROM sysobjects
WHERE type='U'";
break;
case 'postgres':
case 'phpbb_db_driver_postgres':
$sql = 'SELECT relname
FROM pg_stat_user_tables';
break;
case 'firebird':
case 'phpbb_db_driver_firebird':
$sql = 'SELECT rdb$relation_name
FROM rdb$relations
WHERE rdb$view_source is null
AND rdb$system_flag = 0';
break;
case 'oracle':
case 'phpbb_db_driver_oracle':
$sql = 'SELECT table_name
FROM USER_TABLES';
break;
@ -299,8 +299,8 @@ class phpbb_database_test_connection_manager
protected function load_schema_from_file($directory)
{
$schema = $this->dbms['SCHEMA'];
if ($this->config['dbms'] == 'mysql')
if ($this->config['dbms'] == 'phpbb_db_driver_mysql')
{
$sth = $this->pdo->query('SELECT VERSION() AS version');
$row = $sth->fetch(PDO::FETCH_ASSOC);
@ -319,7 +319,7 @@ class phpbb_database_test_connection_manager
$queries = file_get_contents($filename);
$sql = phpbb_remove_comments($queries);
$sql = split_sql_file($sql, $this->dbms['DELIM']);
foreach ($sql as $query)
@ -403,7 +403,7 @@ class phpbb_database_test_connection_manager
switch ($this->config['dbms'])
{
case 'firebird':
case 'phpbb_db_driver_firebird':
$sql = 'SELECT RDB$GENERATOR_NAME
FROM RDB$GENERATORS
WHERE RDB$SYSTEM_FLAG = 0';
@ -415,7 +415,7 @@ class phpbb_database_test_connection_manager
}
break;
case 'oracle':
case 'phpbb_db_driver_oracle':
$sql = 'SELECT sequence_name
FROM USER_SEQUENCES';
$result = $this->pdo->query($sql);

View file

@ -87,12 +87,8 @@ class phpbb_functional_test_case extends phpbb_test_case
// so we don't reopen an open connection
if (!($this->db instanceof dbal))
{
if (!class_exists('dbal_' . self::$config['dbms']))
{
include($phpbb_root_path . 'includes/db/' . self::$config['dbms'] . ".$phpEx");
}
$sql_db = 'dbal_' . self::$config['dbms'];
$this->db = new $sql_db();
$dbms = self::$config['dbms'];
$this->db = new $dbms();
$this->db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']);
}
return $this->db;

View file

@ -54,7 +54,7 @@ class phpbb_test_case_helpers
if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>='))
{
$config = array_merge($config, array(
'dbms' => 'sqlite',
'dbms' => 'phpbb_db_driver_sqlite',
'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename
'dbport' => '',
'dbname' => '',