diff options
author | Andreas Fischer <bantu@phpbb.com> | 2014-06-16 15:14:10 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2014-06-16 15:14:10 +0200 |
commit | 9531691537734fbde3651a3c8b1435eaadec597e (patch) | |
tree | 7484bd00507d490571f1cdbc714203cfbbfadcf5 /phpBB | |
parent | 663c375f5c1547e80f79aae0775eed0039956699 (diff) | |
parent | 754e36e378e9d5d744fcfd6d447bd1e48d2052c3 (diff) | |
download | forums-9531691537734fbde3651a3c8b1435eaadec597e.tar forums-9531691537734fbde3651a3c8b1435eaadec597e.tar.gz forums-9531691537734fbde3651a3c8b1435eaadec597e.tar.bz2 forums-9531691537734fbde3651a3c8b1435eaadec597e.tar.xz forums-9531691537734fbde3651a3c8b1435eaadec597e.zip |
Merge pull request #2607 from Noxwizard/ticket/12643
Ticket/12643 Fixes deletion of columns that have the target column as a prefix
* Noxwizard/ticket/12643:
[ticket/12643] Properly handle changing columns on tables with constraints
[ticket/12643] Tests dropping similarly named columns
[ticket/12643] Ensure that similarly named columns are not removed
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/phpbb/db/tools.php | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 3d065ede8e..2ee842eace 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -1996,7 +1996,7 @@ class tools $columns = implode(',', $column_list); - $new_table_cols = trim(preg_replace('/' . $column_name . '[^,]+(?:,|$)/m', '', $new_table_cols)); + $new_table_cols = trim(preg_replace('/' . $column_name . '\b[^,]+(?:,|$)/m', '', $new_table_cols)); if (substr($new_table_cols, -1) === ',') { // Remove the comma from the last entry again @@ -2561,7 +2561,18 @@ class tools foreach ($old_table_cols as $key => $declaration) { - $entities = preg_split('#\s+#', trim($declaration)); + $declaration = trim($declaration); + + // Check for the beginning of the constraint section and stop + if (preg_match('/[^\(]*\s*PRIMARY KEY\s+\(/', $declaration) || + preg_match('/[^\(]*\s*UNIQUE\s+\(/', $declaration) || + preg_match('/[^\(]*\s*FOREIGN KEY\s+\(/', $declaration) || + preg_match('/[^\(]*\s*CHECK\s+\(/', $declaration)) + { + break; + } + + $entities = preg_split('#\s+#', $declaration); $column_list[] = $entities[0]; if ($entities[0] == $column_name) { |