From 3dcaa48850bf823b238391fbf9c3f085092010bc Mon Sep 17 00:00:00 2001 From: CHItA Date: Sat, 13 Jun 2015 15:35:19 +0200 Subject: [ticket/13740] Move installer files to phpbb/install directory PHPBB3-13740 --- phpBB/phpbb/install/helper/database.php | 459 ++++++++++++++++++++++++++++++++ 1 file changed, 459 insertions(+) create mode 100644 phpBB/phpbb/install/helper/database.php (limited to 'phpBB/phpbb/install/helper/database.php') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php new file mode 100644 index 0000000000..d728c8b93b --- /dev/null +++ b/phpBB/phpbb/install/helper/database.php @@ -0,0 +1,459 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\install\helper; + +use phpbb\install\exception\invalid_dbms_exception; + +/** + * Database related general functionality for installer + */ +class database +{ + /** + * @var \phpbb\filesystem\filesystem_interface + */ + protected $filesystem; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var array + */ + protected $supported_dbms; + + /** + * Constructor + * + * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem interface + * @param string $phpbb_root_path Path to phpBB's root + */ + public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path) + { + $this->filesystem = $filesystem; + + // DBMS supported by phpBB + $this->supported_dbms = array( + // Note: php 5.5 alpha 2 deprecated mysql. + // Keep mysqli before mysql in this list. + 'mysqli' => array( + 'LABEL' => 'MySQL with MySQLi Extension', + 'SCHEMA' => 'mysql_41', + 'MODULE' => 'mysqli', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\mysqli', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mysql' => array( + 'LABEL' => 'MySQL', + 'SCHEMA' => 'mysql', + 'MODULE' => 'mysql', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\mysql', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mssql' => array( + 'LABEL' => 'MS SQL Server 2000+', + 'SCHEMA' => 'mssql', + 'MODULE' => 'mssql', + 'DELIM' => 'GO', + 'DRIVER' => 'phpbb\db\driver\mssql', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mssql_odbc'=> array( + 'LABEL' => 'MS SQL Server [ ODBC ]', + 'SCHEMA' => 'mssql', + 'MODULE' => 'odbc', + 'DELIM' => 'GO', + 'DRIVER' => 'phpbb\db\driver\mssql_odbc', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mssqlnative' => array( + 'LABEL' => 'MS SQL Server 2005+ [ Native ]', + 'SCHEMA' => 'mssql', + 'MODULE' => 'sqlsrv', + 'DELIM' => 'GO', + 'DRIVER' => 'phpbb\db\driver\mssqlnative', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + 'oracle' => array( + 'LABEL' => 'Oracle', + 'SCHEMA' => 'oracle', + 'MODULE' => 'oci8', + 'DELIM' => '/', + 'DRIVER' => 'phpbb\db\driver\oracle', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + 'postgres' => array( + 'LABEL' => 'PostgreSQL 8.3+', + 'SCHEMA' => 'postgres', + 'MODULE' => 'pgsql', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\postgres', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'sqlite' => array( + 'LABEL' => 'SQLite', + 'SCHEMA' => 'sqlite', + 'MODULE' => 'sqlite', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\sqlite', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + 'sqlite3' => array( + 'LABEL' => 'SQLite3', + 'SCHEMA' => 'sqlite', + 'MODULE' => 'sqlite3', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\sqlite3', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + ); + } + + /** + * Returns an array of available DBMS supported by phpBB + * + * If a DBMS is specified it will only return data for that DBMS + * and will load its extension if necessary. + * + * @param mixed $dbms name of the DBMS that's info is required or false for all DBMS info + * @param bool $return_unavailable set it to true if you expect unavailable but supported DBMS + * returned as well + * @param bool $only_20x_options set it to true if you only want to recover 2.0.x options + * + * @return array Array of available and supported DBMS + */ + public function get_available_dbms($dbms = false, $return_unavailable = false, $only_20x_options = false) + { + $available_dbms = $this->supported_dbms; + + if ($dbms) + { + if (isset($this->supported_dbms[$dbms])) + { + $available_dbms = array($dbms => $this->supported_dbms[$dbms]); + } + else + { + return array(); + } + } + + $any_dbms_available = false; + foreach ($available_dbms as $db_name => $db_array) + { + if ($only_20x_options && !$db_array['2.0.x']) + { + if ($return_unavailable) + { + $available_dbms[$db_name]['AVAILABLE'] = false; + } + else + { + unset($available_dbms[$db_name]); + } + + continue; + } + + $dll = $db_array['MODULE']; + if (!@extension_loaded($dll)) + { + if ($return_unavailable) + { + $available_dbms[$db_name]['AVAILABLE'] = false; + } + else + { + unset($available_dbms[$db_name]); + } + + continue; + } + + $any_dbms_available = true; + } + + if ($return_unavailable) + { + $available_dbms['ANY_DB_SUPPORT'] = $any_dbms_available; + } + + return $available_dbms; + } + + /** + * Removes "/* style" as well as "# style" comments from $input. + * + * @param string $sql_query Input string + * + * @return string Input string with comments removed + */ + public function remove_comments($sql_query) + { + // Remove /* */ comments (http://ostermiller.org/findcomment.html) + $sql_query = preg_replace('#/\*(.|[\r\n])*?\*/#', "\n", $sql_query); + + // Remove # style comments + $sql_query = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql_query)); + + return $sql_query; + } + + /** + * split_sql_file() will split an uploaded sql file into single sql statements. + * + * Note: expects trim() to have already been run on $sql. + * + * @param string $sql SQL statements + * @param string $delimiter Delimiter between sql statements + * + * @return array Array of sql statements + */ + public function split_sql_file($sql, $delimiter) + { + $sql = str_replace("\r" , '', $sql); + $data = preg_split('/' . preg_quote($delimiter, '/') . '$/m', $sql); + + $data = array_map('trim', $data); + + // The empty case + $end_data = end($data); + + if (empty($end_data)) + { + unset($data[key($data)]); + } + + return $data; + } + + /** + * Validates table prefix + * + * @param string $dbms The selected dbms + * @param string $table_prefix The table prefix to validate + * + * @return bool|array true if table prefix is valid, array of errors otherwise + * + * @throws \phpbb\install\exception\invalid_dbms_exception When $dbms is not a valid + */ + public function validate_table_prefix($dbms, $table_prefix) + { + $errors = array(); + + if (!preg_match('#^[a-zA-Z][a-zA-Z0-9_]*$#', $table_prefix)) + { + $errors[] = array( + 'title' => 'INST_ERR_DB_INVALID_PREFIX', + ); + } + + // Do dbms specific checks + $dbms_info = $this->get_available_dbms($dbms); + switch ($dbms_info[$dbms]['SCHEMA']) + { + case 'mysql': + case 'mysql_41': + $prefix_length = 36; + break; + case 'mssql': + $prefix_length = 90; + break; + case 'oracle': + $prefix_length = 6; + break; + case 'postgres': + $prefix_length = 36; + break; + case 'sqlite': + $prefix_length = 200; + break; + default: + throw new invalid_dbms_exception(); + break; + } + + // Check the prefix length to ensure that index names are not too long + if (strlen($table_prefix) > $prefix_length) + { + $errors[] = array( + 'title' => array('INST_ERR_PREFIX_TOO_LONG', $prefix_length), + ); + } + + return (empty($errors)) ? true : $errors; + } + + /** + * Check if the user provided database parameters are correct + * + * This function checks the database connection data and also checks for + * any other problems that could cause an error during the installation + * such as if there is any database table names conflicting. + * + * Note: The function assumes that $table_prefix has been already validated + * with validate_table_prefix(). + * + * @param string $dbms Selected database type + * @param string $dbhost Database host address + * @param int $dbport Database port number + * @param string $dbuser Database username + * @param string $dbpass Database password + * @param string $dbname Database name + * @param string $table_prefix Database table prefix + * + * @return array|bool Returns true if test is successful, array of errors otherwise + */ + public function check_database_connection($dbms, $dbhost, $dbport, $dbuser, $dbpass, $dbname, $table_prefix) + { + $dbms_info = $this->get_available_dbms($dbms); + $dbms_info = $dbms_info[$dbms]; + $errors = array(); + + // Instantiate it and set return on error true + /** @var \phpbb\db\driver\driver_interface $db */ + $db = new $dbms_info['DRIVER']; + $db->sql_return_on_error(true); + + // Check that we actually have a database name before going any further + if (!in_array($dbms_info['SCHEMA'], array('sqlite', 'oracle')) && $dbname === '') + { + $errors[] = array( + 'title' => 'INST_ERR_DB_NO_NAME', + ); + } + + // 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_info['SCHEMA'] === 'sqlite' + && stripos($this->filesystem->realpath($dbhost), $this->filesystem->realpath($this->phpbb_root_path) === 0)) + { + $errors[] = array( + 'title' =>'INST_ERR_DB_FORUM_PATH', + ); + } + + // Try to connect to db + if (is_array($db->sql_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport, false, true))) + { + $db_error = $db->sql_error(); + $errors[] = array( + 'title' => 'INST_ERR_DB_CONNECT', + 'description' => ($db_error['message']) ? utf8_convert_message($db_error['message']) : 'INST_ERR_DB_NO_ERROR', + ); + } + else + { + // Check if there is any table name collisions + $temp_prefix = strtolower($table_prefix); + $table_ary = array( + $temp_prefix . 'attachments', + $temp_prefix . 'config', + $temp_prefix . 'sessions', + $temp_prefix . 'topics', + $temp_prefix . 'users', + ); + + $db_tools_factory = new \phpbb\db\tools\factory(); + $db_tools = $db_tools_factory->get($db); + $tables = $db_tools->sql_list_tables(); + $tables = array_map('strtolower', $tables); + $table_intersect = array_intersect($tables, $table_ary); + + if (sizeof($table_intersect)) + { + $errors[] = array( + 'title' => 'INST_ERR_PREFIX', + ); + } + + // Check if database version is supported + switch ($dbms) + { + case 'mysqli': + if (version_compare(mysqli_get_server_info($db->get_db_connect_id()), '4.1.3', '<')) + { + $errors[] = array( + 'title' => 'INST_ERR_DB_NO_MYSQLI', + ); + } + break; + case 'sqlite': + if (version_compare(sqlite_libversion(), '2.8.2', '<')) + { + $errors[] = array( + 'title' => 'INST_ERR_DB_NO_SQLITE', + ); + } + break; + case 'sqlite3': + $version = \SQLite3::version(); + if (version_compare($version['versionString'], '3.6.15', '<')) + { + $errors[] = array( + 'title' => 'INST_ERR_DB_NO_SQLITE3', + ); + } + break; + case 'oracle': + $sql = "SELECT * + FROM NLS_DATABASE_PARAMETERS + WHERE PARAMETER = 'NLS_RDBMS_VERSION' + OR PARAMETER = 'NLS_CHARACTERSET'"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $stats[$row['parameter']] = $row['value']; + } + $db->sql_freeresult($result); + + if (version_compare($stats['NLS_RDBMS_VERSION'], '9.2', '<') && $stats['NLS_CHARACTERSET'] !== 'UTF8') + { + $errors[] = array( + 'title' => 'INST_ERR_DB_NO_ORACLE', + ); + } + break; + case 'postgres': + $sql = "SHOW server_encoding;"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row['server_encoding'] !== 'UNICODE' && $row['server_encoding'] !== 'UTF8') + { + $errors[] = array( + 'title' => 'INST_ERR_DB_NO_POSTGRES', + ); + } + break; + } + } + + return (empty($errors)) ? true : $errors; + } +} -- cgit v1.2.1 From 02029fe1610e5aa1792f24a4d748c6ed08bfc5fc Mon Sep 17 00:00:00 2001 From: CHItA Date: Thu, 18 Jun 2015 14:12:56 +0200 Subject: [ticket/13740] Use DBAL for retrieving DB version PHPBB3-13740 --- phpBB/phpbb/install/helper/database.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install/helper/database.php') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index d728c8b93b..38823c1231 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -394,7 +394,7 @@ class database switch ($dbms) { case 'mysqli': - if (version_compare(mysqli_get_server_info($db->get_db_connect_id()), '4.1.3', '<')) + if (version_compare($db->sql_server_info(), '4.1.3', '<')) { $errors[] = array( 'title' => 'INST_ERR_DB_NO_MYSQLI', @@ -402,7 +402,7 @@ class database } break; case 'sqlite': - if (version_compare(sqlite_libversion(), '2.8.2', '<')) + if (version_compare($db->sql_server_info(), '2.8.2', '<')) { $errors[] = array( 'title' => 'INST_ERR_DB_NO_SQLITE', @@ -410,8 +410,7 @@ class database } break; case 'sqlite3': - $version = \SQLite3::version(); - if (version_compare($version['versionString'], '3.6.15', '<')) + if (version_compare($db->sql_server_info(), '3.6.15', '<')) { $errors[] = array( 'title' => 'INST_ERR_DB_NO_SQLITE3', -- cgit v1.2.1 From 5ad0af3d3df698f7c749fee1f65962e0ba3cf663 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 7 Jul 2015 19:16:58 +0200 Subject: [ticket/13740] Fixes and Tests for database helper PHPBB3-13740 --- phpBB/phpbb/install/helper/database.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/database.php') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 38823c1231..d8751582f7 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -43,7 +43,8 @@ class database */ public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path) { - $this->filesystem = $filesystem; + $this->filesystem = $filesystem; + $this->phpbb_root_path = $phpbb_root_path; // DBMS supported by phpBB $this->supported_dbms = array( -- cgit v1.2.1 From 4d2212a3c2c8528e6d2adde6c57090bf8e26ba7d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 9 Jul 2015 21:52:36 +0200 Subject: [ticket/13740] Fix database version comparison PHPBB3-13740 --- phpBB/phpbb/install/helper/database.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install/helper/database.php') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index d8751582f7..27cb2dc828 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -395,7 +395,7 @@ class database switch ($dbms) { case 'mysqli': - if (version_compare($db->sql_server_info(), '4.1.3', '<')) + if (version_compare($db->sql_server_info(true), '4.1.3', '<')) { $errors[] = array( 'title' => 'INST_ERR_DB_NO_MYSQLI', @@ -403,7 +403,7 @@ class database } break; case 'sqlite': - if (version_compare($db->sql_server_info(), '2.8.2', '<')) + if (version_compare($db->sql_server_info(true), '2.8.2', '<')) { $errors[] = array( 'title' => 'INST_ERR_DB_NO_SQLITE', @@ -411,7 +411,7 @@ class database } break; case 'sqlite3': - if (version_compare($db->sql_server_info(), '3.6.15', '<')) + if (version_compare($db->sql_server_info(true), '3.6.15', '<')) { $errors[] = array( 'title' => 'INST_ERR_DB_NO_SQLITE3', -- cgit v1.2.1 From 0befa9f10900238a2be2c3e50d85de3de9c5edec Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 25 Jul 2015 14:44:39 +0200 Subject: [ticket/13740] Move default data settings out of constructors PHPBB3-13740 --- phpBB/phpbb/install/helper/database.php | 173 ++++++++++++++++---------------- 1 file changed, 85 insertions(+), 88 deletions(-) (limited to 'phpBB/phpbb/install/helper/database.php') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 27cb2dc828..627e9ea9b0 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -33,7 +33,91 @@ class database /** * @var array */ - protected $supported_dbms; + protected $supported_dbms = array( + // Note: php 5.5 alpha 2 deprecated mysql. + // Keep mysqli before mysql in this list. + 'mysqli' => array( + 'LABEL' => 'MySQL with MySQLi Extension', + 'SCHEMA' => 'mysql_41', + 'MODULE' => 'mysqli', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\mysqli', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mysql' => array( + 'LABEL' => 'MySQL', + 'SCHEMA' => 'mysql', + 'MODULE' => 'mysql', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\mysql', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mssql' => array( + 'LABEL' => 'MS SQL Server 2000+', + 'SCHEMA' => 'mssql', + 'MODULE' => 'mssql', + 'DELIM' => 'GO', + 'DRIVER' => 'phpbb\db\driver\mssql', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mssql_odbc'=> array( + 'LABEL' => 'MS SQL Server [ ODBC ]', + 'SCHEMA' => 'mssql', + 'MODULE' => 'odbc', + 'DELIM' => 'GO', + 'DRIVER' => 'phpbb\db\driver\mssql_odbc', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'mssqlnative' => array( + 'LABEL' => 'MS SQL Server 2005+ [ Native ]', + 'SCHEMA' => 'mssql', + 'MODULE' => 'sqlsrv', + 'DELIM' => 'GO', + 'DRIVER' => 'phpbb\db\driver\mssqlnative', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + 'oracle' => array( + 'LABEL' => 'Oracle', + 'SCHEMA' => 'oracle', + 'MODULE' => 'oci8', + 'DELIM' => '/', + 'DRIVER' => 'phpbb\db\driver\oracle', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + 'postgres' => array( + 'LABEL' => 'PostgreSQL 8.3+', + 'SCHEMA' => 'postgres', + 'MODULE' => 'pgsql', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\postgres', + 'AVAILABLE' => true, + '2.0.x' => true, + ), + 'sqlite' => array( + 'LABEL' => 'SQLite', + 'SCHEMA' => 'sqlite', + 'MODULE' => 'sqlite', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\sqlite', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + 'sqlite3' => array( + 'LABEL' => 'SQLite3', + 'SCHEMA' => 'sqlite', + 'MODULE' => 'sqlite3', + 'DELIM' => ';', + 'DRIVER' => 'phpbb\db\driver\sqlite3', + 'AVAILABLE' => true, + '2.0.x' => false, + ), + ); /** * Constructor @@ -45,93 +129,6 @@ class database { $this->filesystem = $filesystem; $this->phpbb_root_path = $phpbb_root_path; - - // DBMS supported by phpBB - $this->supported_dbms = array( - // Note: php 5.5 alpha 2 deprecated mysql. - // Keep mysqli before mysql in this list. - 'mysqli' => array( - 'LABEL' => 'MySQL with MySQLi Extension', - 'SCHEMA' => 'mysql_41', - 'MODULE' => 'mysqli', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mysqli', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mysql' => array( - 'LABEL' => 'MySQL', - 'SCHEMA' => 'mysql', - 'MODULE' => 'mysql', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mysql', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mssql' => array( - 'LABEL' => 'MS SQL Server 2000+', - 'SCHEMA' => 'mssql', - 'MODULE' => 'mssql', - 'DELIM' => 'GO', - 'DRIVER' => 'phpbb\db\driver\mssql', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mssql_odbc'=> array( - 'LABEL' => 'MS SQL Server [ ODBC ]', - 'SCHEMA' => 'mssql', - 'MODULE' => 'odbc', - 'DELIM' => 'GO', - 'DRIVER' => 'phpbb\db\driver\mssql_odbc', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mssqlnative' => array( - 'LABEL' => 'MS SQL Server 2005+ [ Native ]', - 'SCHEMA' => 'mssql', - 'MODULE' => 'sqlsrv', - 'DELIM' => 'GO', - 'DRIVER' => 'phpbb\db\driver\mssqlnative', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - 'oracle' => array( - 'LABEL' => 'Oracle', - 'SCHEMA' => 'oracle', - 'MODULE' => 'oci8', - 'DELIM' => '/', - 'DRIVER' => 'phpbb\db\driver\oracle', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - 'postgres' => array( - 'LABEL' => 'PostgreSQL 8.3+', - 'SCHEMA' => 'postgres', - 'MODULE' => 'pgsql', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\postgres', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'sqlite' => array( - 'LABEL' => 'SQLite', - 'SCHEMA' => 'sqlite', - 'MODULE' => 'sqlite', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\sqlite', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - 'sqlite3' => array( - 'LABEL' => 'SQLite3', - 'SCHEMA' => 'sqlite', - 'MODULE' => 'sqlite3', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\sqlite3', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - ); } /** -- cgit v1.2.1 From 8f5a0ad6f73e7b7757b02c827436384c96069b5a Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 24 Jul 2015 09:20:50 +0200 Subject: [ticket/14039] Revamp updater PHPBB3-14039 --- phpBB/phpbb/install/helper/database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/database.php') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 627e9ea9b0..c4c90a01a4 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -338,7 +338,7 @@ class database $db->sql_return_on_error(true); // Check that we actually have a database name before going any further - if (!in_array($dbms_info['SCHEMA'], array('sqlite', 'oracle')) && $dbname === '') + if (!in_array($dbms_info['SCHEMA'], array('sqlite', 'oracle'), true) && $dbname === '') { $errors[] = array( 'title' => 'INST_ERR_DB_NO_NAME', -- cgit v1.2.1 From 3bafbc81ef11ee76c93eb4f21181d38b5e5c88ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Col=C3=B3n?= Date: Wed, 18 May 2016 14:53:52 -0400 Subject: [ticket/14591] Use the correct delimiter for MSSQL PHPBB3-14591 --- phpBB/phpbb/install/helper/database.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install/helper/database.php') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index c4c90a01a4..b8422fc1ed 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -58,7 +58,7 @@ class database 'LABEL' => 'MS SQL Server 2000+', 'SCHEMA' => 'mssql', 'MODULE' => 'mssql', - 'DELIM' => 'GO', + 'DELIM' => ';', 'DRIVER' => 'phpbb\db\driver\mssql', 'AVAILABLE' => true, '2.0.x' => true, @@ -67,7 +67,7 @@ class database 'LABEL' => 'MS SQL Server [ ODBC ]', 'SCHEMA' => 'mssql', 'MODULE' => 'odbc', - 'DELIM' => 'GO', + 'DELIM' => ';', 'DRIVER' => 'phpbb\db\driver\mssql_odbc', 'AVAILABLE' => true, '2.0.x' => true, @@ -76,7 +76,7 @@ class database 'LABEL' => 'MS SQL Server 2005+ [ Native ]', 'SCHEMA' => 'mssql', 'MODULE' => 'sqlsrv', - 'DELIM' => 'GO', + 'DELIM' => ';', 'DRIVER' => 'phpbb\db\driver\mssqlnative', 'AVAILABLE' => true, '2.0.x' => false, -- cgit v1.2.1 From c64b8102b7c5dc5bd0be9d8085d01a66e90dde73 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Tue, 29 Mar 2016 21:21:35 +0200 Subject: [ticket/10809] Remove MSSQL support PHPBB3-10809 --- phpBB/phpbb/install/helper/database.php | 9 --------- 1 file changed, 9 deletions(-) (limited to 'phpBB/phpbb/install/helper/database.php') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index b8422fc1ed..be0c953d28 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -54,15 +54,6 @@ class database 'AVAILABLE' => true, '2.0.x' => true, ), - 'mssql' => array( - 'LABEL' => 'MS SQL Server 2000+', - 'SCHEMA' => 'mssql', - 'MODULE' => 'mssql', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mssql', - 'AVAILABLE' => true, - '2.0.x' => true, - ), 'mssql_odbc'=> array( 'LABEL' => 'MS SQL Server [ ODBC ]', 'SCHEMA' => 'mssql', -- cgit v1.2.1 From e974f338afb86c065e9b160363bc2e6156f8566d Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Sun, 13 Nov 2016 18:08:35 +0100 Subject: [ticket/14739] Remove SQLite 2.8.x database driver PHPBB3-14739 --- phpBB/phpbb/install/helper/database.php | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'phpBB/phpbb/install/helper/database.php') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index be0c953d28..192f0a3654 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -90,15 +90,6 @@ class database 'AVAILABLE' => true, '2.0.x' => true, ), - 'sqlite' => array( - 'LABEL' => 'SQLite', - 'SCHEMA' => 'sqlite', - 'MODULE' => 'sqlite', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\sqlite', - 'AVAILABLE' => true, - '2.0.x' => false, - ), 'sqlite3' => array( 'LABEL' => 'SQLite3', 'SCHEMA' => 'sqlite', @@ -390,14 +381,6 @@ class database ); } break; - case 'sqlite': - if (version_compare($db->sql_server_info(true), '2.8.2', '<')) - { - $errors[] = array( - 'title' => 'INST_ERR_DB_NO_SQLITE', - ); - } - break; case 'sqlite3': if (version_compare($db->sql_server_info(true), '3.6.15', '<')) { -- cgit v1.2.1 From e6bdba7da1069c71e9b3c148266d0cd90b6cf1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Thu, 15 Jun 2017 16:56:19 +0200 Subject: [ticket/15243] Check permissions before installing with SQLite PHPBB3-15243 --- phpBB/phpbb/install/helper/database.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/phpbb/install/helper/database.php') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 192f0a3654..59b86a8ca7 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -336,6 +336,15 @@ class database ); } + // Check if SQLite database is writable + if ($dbms_info['SCHEMA'] === 'sqlite' + && (!$this->filesystem->is_writable($dbhost) || !$this->filesystem->is_writable(pathinfo($dbhost, PATHINFO_DIRNAME)))) + { + $errors[] = array( + 'title' =>'INST_ERR_DB_NO_WRITABLE', + ); + } + // Try to connect to db if (is_array($db->sql_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport, false, true))) { -- cgit v1.2.1 From f8fbe3793680af1dae2db2829cfc84068831c52f Mon Sep 17 00:00:00 2001 From: rxu Date: Wed, 28 Jun 2017 00:58:03 +0700 Subject: [ticket/14972] replace all occurrences of sizeof() with the count() PHPBB3-14972 --- phpBB/phpbb/install/helper/database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/database.php') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 59b86a8ca7..ad0f3dd3cd 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -372,7 +372,7 @@ class database $tables = array_map('strtolower', $tables); $table_intersect = array_intersect($tables, $table_ary); - if (sizeof($table_intersect)) + if (count($table_intersect)) { $errors[] = array( 'title' => 'INST_ERR_PREFIX', -- cgit v1.2.1 From c160882cdbf892e2d19d2990502f0e918dda75e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sat, 17 Feb 2018 18:50:04 +0100 Subject: [ticket/15563] Check if database file is writable only if exists PHPBB3-15563 --- phpBB/phpbb/install/helper/database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/database.php') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index ad0f3dd3cd..21af652f9d 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -338,7 +338,7 @@ class database // Check if SQLite database is writable if ($dbms_info['SCHEMA'] === 'sqlite' - && (!$this->filesystem->is_writable($dbhost) || !$this->filesystem->is_writable(pathinfo($dbhost, PATHINFO_DIRNAME)))) + && (($this->filesystem->exists($dbhost) && !$this->filesystem->is_writable($dbhost)) || !$this->filesystem->is_writable(pathinfo($dbhost, PATHINFO_DIRNAME)))) { $errors[] = array( 'title' =>'INST_ERR_DB_NO_WRITABLE', -- cgit v1.2.1 From 3a2374e37c92bece4a7c87484ff4e8e22697142f Mon Sep 17 00:00:00 2001 From: hubaishan Date: Mon, 1 Oct 2018 20:25:55 +0300 Subject: [ticket/15817] Fix installtion failed with Oracle Fix installtion failed with Oracle PHPBB3-15817 --- phpBB/phpbb/install/helper/database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/database.php') diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index 21af652f9d..fa5a10c6fc 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -76,7 +76,7 @@ class database 'LABEL' => 'Oracle', 'SCHEMA' => 'oracle', 'MODULE' => 'oci8', - 'DELIM' => '/', + 'DELIM' => ';', 'DRIVER' => 'phpbb\db\driver\oracle', 'AVAILABLE' => true, '2.0.x' => false, -- cgit v1.2.1