mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge remote-tracking branch 'Noxwizard/ticket/10349' into develop-olympus
* Noxwizard/ticket/10349: [ticket/10349] Removed duplicated functions from schema loading in tests [ticket/10349] Update function comment [ticket/10349] Use new schema comment function in installer [ticket/10349] Unit tests: Consolidate schema comment removal functions [ticket/10349] Unit tests: Remove comments while loading schema files
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_install.php';
|
||||
|
||||
class phpbb_database_test_connection_manager
|
||||
{
|
||||
private $config;
|
||||
@@ -239,7 +241,11 @@ class phpbb_database_test_connection_manager
|
||||
}
|
||||
|
||||
$filename = $directory . $schema . '_schema.sql';
|
||||
$sql = $this->split_sql(file_get_contents($filename));
|
||||
|
||||
$queries = file_get_contents($filename);
|
||||
$sql = remove_comments($queries);
|
||||
|
||||
$sql = split_sql_file($sql, $this->dbms['DELIM']);
|
||||
|
||||
foreach ($sql as $query)
|
||||
{
|
||||
@@ -247,43 +253,6 @@ class phpbb_database_test_connection_manager
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Split contents of an SQL file into an array of SQL statements
|
||||
*
|
||||
* Note: This method is not the same as split_sql_file from functions_install.
|
||||
*
|
||||
* @param string $sql Raw contents of an SQL file
|
||||
*
|
||||
* @return Array of runnable SQL statements
|
||||
*/
|
||||
protected function split_sql($sql)
|
||||
{
|
||||
$sql = str_replace("\r" , '', $sql);
|
||||
$data = preg_split('/' . preg_quote($this->dbms['DELIM'], '/') . '$/m', $sql);
|
||||
|
||||
$data = array_map('trim', $data);
|
||||
|
||||
// The empty case
|
||||
$end_data = end($data);
|
||||
|
||||
if (empty($end_data))
|
||||
{
|
||||
unset($data[key($data)]);
|
||||
}
|
||||
|
||||
if ($this->config['dbms'] == 'sqlite')
|
||||
{
|
||||
// remove comment lines starting with # - they are not proper sqlite
|
||||
// syntax and break sqlite2
|
||||
foreach ($data as $i => $query)
|
||||
{
|
||||
$data[$i] = preg_replace('/^#.*$/m', "\n", $query);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a phpBB dbms driver name to dbms data array
|
||||
*/
|
||||
|
Reference in New Issue
Block a user