[ticket/17509] Add installer DBMS version checks

PHPBB-17509
This commit is contained in:
rxu 2025-05-29 20:11:07 +07:00
parent 215d1bf1eb
commit bf2c22354a
No known key found for this signature in database
GPG key ID: 955F0567380E586A
2 changed files with 43 additions and 28 deletions

View file

@ -184,9 +184,9 @@ $lang = array_merge($lang, array(
'TABLE_PREFIX_EXPLAIN' => 'The prefix must start with a letter and must only contain letters, numbers and underscores.', 'TABLE_PREFIX_EXPLAIN' => 'The prefix must start with a letter and must only contain letters, numbers and underscores.',
// Database options // Database options
'DB_OPTION_MSSQL_ODBC' => 'MSSQL Server 2000+ via ODBC', 'DB_OPTION_MSSQL_ODBC' => 'MSSQL Server via ODBC',
'DB_OPTION_MSSQLNATIVE' => 'MSSQL Server 2005+ [ Native ]', 'DB_OPTION_MSSQLNATIVE' => 'MSSQL Server [ Native ]',
'DB_OPTION_MYSQLI' => 'MySQL with MySQLi Extension', 'DB_OPTION_MYSQLI' => 'MySQL',
'DB_OPTION_ORACLE' => 'Oracle', 'DB_OPTION_ORACLE' => 'Oracle',
'DB_OPTION_POSTGRES' => 'PostgreSQL', 'DB_OPTION_POSTGRES' => 'PostgreSQL',
'DB_OPTION_SQLITE3' => 'SQLite 3', 'DB_OPTION_SQLITE3' => 'SQLite 3',
@ -202,7 +202,8 @@ $lang = array_merge($lang, array(
'INST_ERR_DB_NO_WRITABLE' => 'Both the database and the directory containing it must be writable.', 'INST_ERR_DB_NO_WRITABLE' => 'Both the database and the directory containing it must be writable.',
'INST_ERR_DB_NO_ERROR' => 'No error message given.', 'INST_ERR_DB_NO_ERROR' => 'No error message given.',
'INST_ERR_PREFIX' => 'Tables with the specified prefix already exist, please choose an alternative.', 'INST_ERR_PREFIX' => 'Tables with the specified prefix already exist, please choose an alternative.',
'INST_ERR_DB_NO_MYSQLI' => 'The version of MySQL installed on this machine is incompatible with the “MySQL with MySQLi Extension” option you have selected. Please try the “MySQL” option instead.', 'INST_ERR_DB_NO_MYSQLI' => 'The version of MySQL installed on this machine is too old, it must be upgraded to at least 5.6.',
'INST_ERR_DB_NO_MSSQL' => 'The version of Microsoft SQL Server installed on this machine is too old, it must be upgraded to at least SQL Server 2012 (11.0.2100.60)',
'INST_ERR_DB_NO_SQLITE3' => 'The version of the SQLite extension you have installed is too old, it must be upgraded to at least 3.8.3.', 'INST_ERR_DB_NO_SQLITE3' => 'The version of the SQLite extension you have installed is too old, it must be upgraded to at least 3.8.3.',
'INST_ERR_DB_NO_ORACLE' => 'The version of Oracle installed is too old, it must be upgraded to at least 12.1.0.2.', 'INST_ERR_DB_NO_ORACLE' => 'The version of Oracle installed is too old, it must be upgraded to at least 12.1.0.2.',
'INST_ERR_DB_NO_POSTGRES' => 'The version of the PostgreSQL you have installed is too old, it must be upgraded to at least 9.4.', 'INST_ERR_DB_NO_POSTGRES' => 'The version of the PostgreSQL you have installed is too old, it must be upgraded to at least 9.4.',

View file

@ -39,7 +39,7 @@ class database
// Note: php 5.5 alpha 2 deprecated mysql. // Note: php 5.5 alpha 2 deprecated mysql.
// Keep mysqli before mysql in this list. // Keep mysqli before mysql in this list.
'mysqli' => array( 'mysqli' => array(
'LABEL' => 'MySQL with MySQLi Extension', 'LABEL' => 'MySQL',
'SCHEMA' => 'mysql_41', 'SCHEMA' => 'mysql_41',
'MODULE' => 'mysqli', 'MODULE' => 'mysqli',
'DOCTRINE' => ['pdo_mysql'], 'DOCTRINE' => ['pdo_mysql'],
@ -59,7 +59,7 @@ class database
'2.0.x' => true, '2.0.x' => true,
), ),
'mssqlnative' => array( 'mssqlnative' => array(
'LABEL' => 'MS SQL Server 2005+ [ Native ]', 'LABEL' => 'MS SQL Server [ Native ]',
'SCHEMA' => 'mssql', 'SCHEMA' => 'mssql',
'MODULE' => 'sqlsrv', 'MODULE' => 'sqlsrv',
'DOCTRINE' => ['pdo_sqlsrv'], 'DOCTRINE' => ['pdo_sqlsrv'],
@ -78,7 +78,7 @@ class database
'2.0.x' => false, '2.0.x' => false,
), ),
'postgres' => array( 'postgres' => array(
'LABEL' => 'PostgreSQL 8.3+', 'LABEL' => 'PostgreSQL',
'SCHEMA' => 'postgres', 'SCHEMA' => 'postgres',
'MODULE' => 'pgsql', 'MODULE' => 'pgsql',
'DOCTRINE' => ['pdo_pgsql'], 'DOCTRINE' => ['pdo_pgsql'],
@ -405,10 +405,19 @@ class database
} }
// Check if database version is supported // Check if database version is supported
$db_server_version = $doctrine_db->getWrappedConnection()->getServerVersion();
switch ($dbms) switch ($dbms)
{ {
case 'mysqli':
if (version_compare($db_server_version, '5.6', '<'))
{
$errors[] = array(
'title' => 'INST_ERR_DB_NO_MYSQLI',
);
}
break;
case 'sqlite3': case 'sqlite3':
if (version_compare($db->sql_server_info(true), '3.8.3', '<')) if (version_compare($db_server_version, '3.8.3', '<'))
{ {
$errors[] = array( $errors[] = array(
'title' => 'INST_ERR_DB_NO_SQLITE3', 'title' => 'INST_ERR_DB_NO_SQLITE3',
@ -416,20 +425,7 @@ class database
} }
break; break;
case 'oracle': case 'oracle':
$sql = "SELECT * if (version_compare($db_server_version, '12.1.0.2', '<'))
FROM NLS_DATABASE_PARAMETERS
WHERE PARAMETER = 'NLS_RDBMS_VERSION'
OR PARAMETER = 'NLS_CHARACTERSET'";
$result = $db->sql_query($sql);
$stats = [];
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( $errors[] = array(
'title' => 'INST_ERR_DB_NO_ORACLE', 'title' => 'INST_ERR_DB_NO_ORACLE',
@ -437,17 +433,35 @@ class database
} }
break; break;
case 'postgres': case 'postgres':
$sql = "SHOW server_encoding;"; if (version_compare($db_server_version, '9.4', '<'))
$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( $errors[] = array(
'title' => 'INST_ERR_DB_NO_POSTGRES', 'title' => 'INST_ERR_DB_NO_POSTGRES',
); );
} }
else
{
$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_UTF8',
);
}
}
break;
case 'mssqlnative':
case 'mssql_odbc':
if (version_compare($db_server_version, '11.0.2100.60', '<'))
{
$errors[] = array(
'title' => 'INST_ERR_DB_NO_MSSQL',
);
}
break; break;
} }
} }