From 754e36e378e9d5d744fcfd6d447bd1e48d2052c3 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Sun, 15 Jun 2014 14:52:05 -0500 Subject: [ticket/12643] Properly handle changing columns on tables with constraints PHPBB3-12643 --- phpBB/phpbb/db/tools.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/db') diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 3b329b47bc..2ee842eace 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -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) { -- cgit v1.2.1