[ticket/11700] Get the installer to run with namespaces

PHPBB3-11700
This commit is contained in:
Nils Adermann 2013-09-10 17:13:29 +02:00
parent 9a2c29a175
commit d297eb4aec
4 changed files with 39 additions and 32 deletions

View file

@ -5647,9 +5647,9 @@ function phpbb_convert_30_dbms_to_31($dbms)
// true for mysqli class. // true for mysqli class.
// However, per the docblock any valid 3.1 driver name should be // However, per the docblock any valid 3.1 driver name should be
// recognized by this function, and have priority over 3.0 dbms. // recognized by this function, and have priority over 3.0 dbms.
if (class_exists('\phpbb\db\driver\\' . $dbms)) if (class_exists('phpbb\db\driver\\' . $dbms))
{ {
return '\phpbb\db\driver\\' . $dbms; return 'phpbb\db\driver\\' . $dbms;
} }
if (class_exists($dbms)) if (class_exists($dbms))

View file

@ -28,7 +28,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'firebird', 'SCHEMA' => 'firebird',
'MODULE' => 'interbase', 'MODULE' => 'interbase',
'DELIM' => ';;', 'DELIM' => ';;',
'DRIVER' => '\phpbb\db\driver\firebird', 'DRIVER' => 'phpbb\db\driver\firebird',
'AVAILABLE' => true, 'AVAILABLE' => true,
'2.0.x' => false, '2.0.x' => false,
), ),
@ -39,7 +39,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mysql_41', 'SCHEMA' => 'mysql_41',
'MODULE' => 'mysqli', 'MODULE' => 'mysqli',
'DELIM' => ';', 'DELIM' => ';',
'DRIVER' => '\phpbb\db\driver\mysqli', 'DRIVER' => 'phpbb\db\driver\mysqli',
'AVAILABLE' => true, 'AVAILABLE' => true,
'2.0.x' => true, '2.0.x' => true,
), ),
@ -48,7 +48,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mysql', 'SCHEMA' => 'mysql',
'MODULE' => 'mysql', 'MODULE' => 'mysql',
'DELIM' => ';', 'DELIM' => ';',
'DRIVER' => '\phpbb\db\driver\mysql', 'DRIVER' => 'phpbb\db\driver\mysql',
'AVAILABLE' => true, 'AVAILABLE' => true,
'2.0.x' => true, '2.0.x' => true,
), ),
@ -57,7 +57,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mssql', 'SCHEMA' => 'mssql',
'MODULE' => 'mssql', 'MODULE' => 'mssql',
'DELIM' => 'GO', 'DELIM' => 'GO',
'DRIVER' => '\phpbb\db\driver\mssql', 'DRIVER' => 'phpbb\db\driver\mssql',
'AVAILABLE' => true, 'AVAILABLE' => true,
'2.0.x' => true, '2.0.x' => true,
), ),
@ -66,7 +66,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mssql', 'SCHEMA' => 'mssql',
'MODULE' => 'odbc', 'MODULE' => 'odbc',
'DELIM' => 'GO', 'DELIM' => 'GO',
'DRIVER' => '\phpbb\db\driver\mssql_odbc', 'DRIVER' => 'phpbb\db\driver\mssql_odbc',
'AVAILABLE' => true, 'AVAILABLE' => true,
'2.0.x' => true, '2.0.x' => true,
), ),
@ -75,7 +75,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mssql', 'SCHEMA' => 'mssql',
'MODULE' => 'sqlsrv', 'MODULE' => 'sqlsrv',
'DELIM' => 'GO', 'DELIM' => 'GO',
'DRIVER' => '\phpbb\db\driver\mssqlnative', 'DRIVER' => 'phpbb\db\driver\mssqlnative',
'AVAILABLE' => true, 'AVAILABLE' => true,
'2.0.x' => false, '2.0.x' => false,
), ),
@ -84,7 +84,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'oracle', 'SCHEMA' => 'oracle',
'MODULE' => 'oci8', 'MODULE' => 'oci8',
'DELIM' => '/', 'DELIM' => '/',
'DRIVER' => '\phpbb\db\driver\oracle', 'DRIVER' => 'phpbb\db\driver\oracle',
'AVAILABLE' => true, 'AVAILABLE' => true,
'2.0.x' => false, '2.0.x' => false,
), ),
@ -93,7 +93,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'postgres', 'SCHEMA' => 'postgres',
'MODULE' => 'pgsql', 'MODULE' => 'pgsql',
'DELIM' => ';', 'DELIM' => ';',
'DRIVER' => '\phpbb\db\driver\postgres', 'DRIVER' => 'phpbb\db\driver\postgres',
'AVAILABLE' => true, 'AVAILABLE' => true,
'2.0.x' => true, '2.0.x' => true,
), ),
@ -102,7 +102,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'sqlite', 'SCHEMA' => 'sqlite',
'MODULE' => 'sqlite', 'MODULE' => 'sqlite',
'DELIM' => ';', 'DELIM' => ';',
'DRIVER' => '\phpbb\db\driver\sqlite', 'DRIVER' => 'phpbb\db\driver\sqlite',
'AVAILABLE' => true, 'AVAILABLE' => true,
'2.0.x' => false, '2.0.x' => false,
), ),
@ -206,14 +206,14 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
$db->sql_return_on_error(true); $db->sql_return_on_error(true);
// Check that we actually have a database name before going any further..... // Check that we actually have a database name before going any further.....
if ($dbms_details['DRIVER'] != '\phpbb\db\driver\sqlite' && $dbms_details['DRIVER'] != '\phpbb\db\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']; $error[] = $lang['INST_ERR_DB_NO_NAME'];
return false; 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 // 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'] == '\phpbb\db\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']; $error[] = $lang['INST_ERR_DB_FORUM_PATH'];
return false; return false;
@ -222,8 +222,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 // Check the prefix length to ensure that index names are not too long and does not contain invalid characters
switch ($dbms_details['DRIVER']) switch ($dbms_details['DRIVER'])
{ {
case '\phpbb\db\driver\mysql': case 'phpbb\db\driver\mysql':
case '\phpbb\db\driver\mysqli': case 'phpbb\db\driver\mysqli':
if (strspn($table_prefix, '-./\\') !== 0) if (strspn($table_prefix, '-./\\') !== 0)
{ {
$error[] = $lang['INST_ERR_PREFIX_INVALID']; $error[] = $lang['INST_ERR_PREFIX_INVALID'];
@ -232,22 +232,22 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
// no break; // no break;
case '\phpbb\db\driver\postgres': case 'phpbb\db\driver\postgres':
$prefix_length = 36; $prefix_length = 36;
break; break;
case '\phpbb\db\driver\mssql': case 'phpbb\db\driver\mssql':
case '\phpbb\db\driver\mssql_odbc': case 'phpbb\db\driver\mssql_odbc':
case '\phpbb\db\driver\mssqlnative': case 'phpbb\db\driver\mssqlnative':
$prefix_length = 90; $prefix_length = 90;
break; break;
case '\phpbb\db\driver\sqlite': case 'phpbb\db\driver\sqlite':
$prefix_length = 200; $prefix_length = 200;
break; break;
case '\phpbb\db\driver\firebird': case 'phpbb\db\driver\firebird':
case '\phpbb\db\driver\oracle': case 'phpbb\db\driver\oracle':
$prefix_length = 6; $prefix_length = 6;
break; break;
} }
@ -285,21 +285,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 // Make sure that the user has selected a sensible DBAL for the DBMS actually installed
switch ($dbms_details['DRIVER']) switch ($dbms_details['DRIVER'])
{ {
case '\phpbb\db\driver\mysqli': case 'phpbb\db\driver\mysqli':
if (version_compare(mysqli_get_server_info($db->db_connect_id), '4.1.3', '<')) if (version_compare(mysqli_get_server_info($db->db_connect_id), '4.1.3', '<'))
{ {
$error[] = $lang['INST_ERR_DB_NO_MYSQLI']; $error[] = $lang['INST_ERR_DB_NO_MYSQLI'];
} }
break; break;
case '\phpbb\db\driver\sqlite': case 'phpbb\db\driver\sqlite':
if (version_compare(sqlite_libversion(), '2.8.2', '<')) if (version_compare(sqlite_libversion(), '2.8.2', '<'))
{ {
$error[] = $lang['INST_ERR_DB_NO_SQLITE']; $error[] = $lang['INST_ERR_DB_NO_SQLITE'];
} }
break; break;
case '\phpbb\db\driver\firebird': case 'phpbb\db\driver\firebird':
// check the version of FB, use some hackery if we can't get access to the server info // 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')) if ($db->service_handle !== false && function_exists('ibase_server_info'))
{ {
@ -380,7 +380,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
} }
break; break;
case '\phpbb\db\driver\oracle': case 'phpbb\db\driver\oracle':
if ($unicode_check) if ($unicode_check)
{ {
$sql = "SELECT * $sql = "SELECT *
@ -402,7 +402,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
} }
break; break;
case '\phpbb\db\driver\postgres': case 'phpbb\db\driver\postgres':
if ($unicode_check) if ($unicode_check)
{ {
$sql = "SHOW server_encoding;"; $sql = "SHOW server_encoding;";
@ -507,7 +507,7 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_test
'adm_relative_path' => 'adm/', 'adm_relative_path' => 'adm/',
'acm_type' => '\phpbb\cache\driver\file', 'acm_type' => 'phpbb\cache\driver\file',
); );
foreach ($config_data_array as $key => $value) foreach ($config_data_array as $key => $value)

View file

@ -7,7 +7,7 @@
* *
*/ */
namespace phpbb\db\migration\data0; namespace phpbb\db\migration\data\v310;
class style_update_p2 extends \phpbb\db\migration\migration class style_update_p2 extends \phpbb\db\migration\migration
{ {

View file

@ -277,10 +277,17 @@ class finder
$classes = array(); $classes = array();
foreach ($files as $file => $ext_name) foreach ($files as $file => $ext_name)
{ {
$file = preg_replace('#^(phpbb|includes)/#', '', $file); if (preg_match('#^includes/#', $file))
{
$file = preg_replace('#^includes/#', '', $file);
$classes[] = 'phpbb_' . str_replace('/', '_', substr($file, 0, -strlen('.' . $this->php_ext))); $classes[] = 'phpbb_' . str_replace('/', '_', substr($file, 0, -strlen('.' . $this->php_ext)));
} }
else
{
$file = preg_replace('#^phpbb/#', '', $file);
$classes[] = 'phpbb\\' . str_replace('/', '\\', substr($file, 0, -strlen('.' . $this->php_ext)));
}
}
return $classes; return $classes;
} }