aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-12-03 22:25:32 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2011-12-03 22:25:32 -0500
commit0c0befe2f858ec2c53e92ab06455392c6bb118f0 (patch)
tree61f8da25d7a7cc5ee2ef3ea908b7486ef734b219 /phpBB
parent3176dcbc05383ab7cb72e228ab7b2ea1929643ab (diff)
parentbf6d501ab16f0557c0570faa2a6f45e588ff62fb (diff)
downloadforums-0c0befe2f858ec2c53e92ab06455392c6bb118f0.tar
forums-0c0befe2f858ec2c53e92ab06455392c6bb118f0.tar.gz
forums-0c0befe2f858ec2c53e92ab06455392c6bb118f0.tar.bz2
forums-0c0befe2f858ec2c53e92ab06455392c6bb118f0.tar.xz
forums-0c0befe2f858ec2c53e92ab06455392c6bb118f0.zip
Merge branch 'develop-olympus' into develop
* develop-olympus: [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
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/functions_admin.php35
-rw-r--r--phpBB/includes/functions_install.php19
-rw-r--r--phpBB/install/install_install.php6
3 files changed, 10 insertions, 50 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 82fe97bd6d..f6378e331e 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -2295,41 +2295,6 @@ function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_fr
}
/**
-* remove_comments will strip the sql comment lines out of an uploaded sql file
-* specifically for mssql and postgres type files in the install....
-*/
-function remove_comments(&$output)
-{
- $lines = explode("\n", $output);
- $output = '';
-
- // try to keep mem. use down
- $linecount = sizeof($lines);
-
- $in_comment = false;
- for ($i = 0; $i < $linecount; $i++)
- {
- if (trim($lines[$i]) == '/*')
- {
- $in_comment = true;
- }
-
- if (!$in_comment)
- {
- $output .= $lines[$i] . "\n";
- }
-
- if (trim($lines[$i]) == '*/')
- {
- $in_comment = false;
- }
- }
-
- unset($lines);
- return $output;
-}
-
-/**
* Cache moderators, called whenever permissions are changed via admin_permissions. Changes of username
* and group names must be carried through for the moderators table
*/
diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php
index 7a99bca0e2..b0d8fb6720 100644
--- a/phpBB/includes/functions_install.php
+++ b/phpBB/includes/functions_install.php
@@ -50,7 +50,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'firebird',
'MODULE' => 'interbase',
'DELIM' => ';;',
- 'COMMENTS' => 'remove_remarks',
'DRIVER' => 'firebird',
'AVAILABLE' => true,
'2.0.x' => false,
@@ -60,7 +59,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mysql_41',
'MODULE' => 'mysqli',
'DELIM' => ';',
- 'COMMENTS' => 'remove_remarks',
'DRIVER' => 'mysqli',
'AVAILABLE' => true,
'2.0.x' => true,
@@ -70,7 +68,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mysql',
'MODULE' => 'mysql',
'DELIM' => ';',
- 'COMMENTS' => 'remove_remarks',
'DRIVER' => 'mysql',
'AVAILABLE' => true,
'2.0.x' => true,
@@ -80,7 +77,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mssql',
'MODULE' => 'mssql',
'DELIM' => 'GO',
- 'COMMENTS' => 'remove_comments',
'DRIVER' => 'mssql',
'AVAILABLE' => true,
'2.0.x' => true,
@@ -90,7 +86,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mssql',
'MODULE' => 'odbc',
'DELIM' => 'GO',
- 'COMMENTS' => 'remove_comments',
'DRIVER' => 'mssql_odbc',
'AVAILABLE' => true,
'2.0.x' => true,
@@ -100,7 +95,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mssql',
'MODULE' => 'sqlsrv',
'DELIM' => 'GO',
- 'COMMENTS' => 'remove_comments',
'DRIVER' => 'mssqlnative',
'AVAILABLE' => true,
'2.0.x' => false,
@@ -110,7 +104,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'oracle',
'MODULE' => 'oci8',
'DELIM' => '/',
- 'COMMENTS' => 'remove_comments',
'DRIVER' => 'oracle',
'AVAILABLE' => true,
'2.0.x' => false,
@@ -120,7 +113,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'postgres',
'MODULE' => 'pgsql',
'DELIM' => ';',
- 'COMMENTS' => 'remove_comments',
'DRIVER' => 'postgres',
'AVAILABLE' => true,
'2.0.x' => true,
@@ -130,7 +122,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'sqlite',
'MODULE' => 'sqlite',
'DELIM' => ';',
- 'COMMENTS' => 'remove_remarks',
'DRIVER' => 'sqlite',
'AVAILABLE' => true,
'2.0.x' => false,
@@ -473,11 +464,17 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
}
/**
-* remove_remarks will strip the sql comment lines out of an uploaded sql file
+* Removes comments from schema files
*/
-function remove_remarks(&$sql)
+function remove_comments($sql)
{
+ // Remove /* */ comments (http://ostermiller.org/findcomment.html)
+ $sql = preg_replace('#/\*(.|[\r\n])*?\*/#', "\n", $sql);
+
+ // Remove # style comments
$sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql));
+
+ return $sql;
}
/**
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index 6d86395f06..21fe355447 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -1152,14 +1152,13 @@ class install_install extends module
$dbms_schema = 'schemas/' . $available_dbms[$data['dbms']]['SCHEMA'] . '_schema.sql';
// How should we treat this schema?
- $remove_remarks = $available_dbms[$data['dbms']]['COMMENTS'];
$delimiter = $available_dbms[$data['dbms']]['DELIM'];
$sql_query = @file_get_contents($dbms_schema);
$sql_query = preg_replace('#phpbb_#i', $data['table_prefix'], $sql_query);
- $remove_remarks($sql_query);
+ $sql_query = remove_comments($sql_query);
$sql_query = split_sql_file($sql_query, $delimiter);
@@ -1197,8 +1196,7 @@ class install_install extends module
// Change language strings...
$sql_query = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', 'adjust_language_keys_callback', $sql_query);
- // Since there is only one schema file we know the comment style and are able to remove it directly with remove_remarks
- remove_remarks($sql_query);
+ $sql_query = remove_comments($sql_query);
$sql_query = split_sql_file($sql_query, ';');
foreach ($sql_query as $sql)