mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
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
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user