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 | cebe7c8028281be116a438a0683eaab227afe994 (patch) | |
| tree | 12b37ad89f5e8a6f530c2f6060cfdf48a6a86141 /phpBB/phpbb | |
| parent | 6299dcd578a9265af5543c88770bc061af550f37 (diff) | |
| parent | 9531691537734fbde3651a3c8b1435eaadec597e (diff) | |
| download | forums-cebe7c8028281be116a438a0683eaab227afe994.tar forums-cebe7c8028281be116a438a0683eaab227afe994.tar.gz forums-cebe7c8028281be116a438a0683eaab227afe994.tar.bz2 forums-cebe7c8028281be116a438a0683eaab227afe994.tar.xz forums-cebe7c8028281be116a438a0683eaab227afe994.zip | |
Merge branch 'develop-ascraeus' into develop
* develop-ascraeus:
[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/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) { |
