From 9ddf02243e37adb27984ef34e208943a413266b8 Mon Sep 17 00:00:00 2001 From: PayBas Date: Sun, 18 May 2014 15:55:28 +0200 Subject: [ticket/12561] Add "after" check to schema_generator for columns_add PHPBB3-12561 --- phpBB/phpbb/db/migration/schema_generator.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/db/migration/schema_generator.php b/phpBB/phpbb/db/migration/schema_generator.php index 5d40b0b26f..872430e078 100644 --- a/phpBB/phpbb/db/migration/schema_generator.php +++ b/phpBB/phpbb/db/migration/schema_generator.php @@ -107,7 +107,17 @@ class schema_generator { foreach ($add_columns as $column => $column_data) { - $this->tables[$table]['COLUMNS'][$column] = $column_data; + if (isset($column_data['after'])) + { + $columns = $this->tables[$table]['COLUMNS']; + $offset = array_search($column_data['after'], array_keys($columns)); + unset($column_data['after']); + $this->tables[$table]['COLUMNS'] = array_merge(array_slice($columns, 0, $offset + 1, true), array($column => array_values($column_data)), array_slice($columns, $offset)); + } + else + { + $this->tables[$table]['COLUMNS'][$column] = $column_data; + } } } } -- cgit v1.2.1 From c51b926631eb8e339c7a29cf3ff145e9e158b04f Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 26 May 2014 19:28:37 +0200 Subject: [ticket/12561] Add check to see if "after" column actually exists If not, just append to the end PHPBB3-12561 --- phpBB/phpbb/db/migration/schema_generator.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/db/migration/schema_generator.php b/phpBB/phpbb/db/migration/schema_generator.php index 872430e078..f36e6a96d5 100644 --- a/phpBB/phpbb/db/migration/schema_generator.php +++ b/phpBB/phpbb/db/migration/schema_generator.php @@ -112,7 +112,15 @@ class schema_generator $columns = $this->tables[$table]['COLUMNS']; $offset = array_search($column_data['after'], array_keys($columns)); unset($column_data['after']); - $this->tables[$table]['COLUMNS'] = array_merge(array_slice($columns, 0, $offset + 1, true), array($column => array_values($column_data)), array_slice($columns, $offset)); + + if ($offset == false) + { + $this->tables[$table]['COLUMNS'][$column] = array_values($column_data); + } + else + { + $this->tables[$table]['COLUMNS'] = array_merge(array_slice($columns, 0, $offset + 1, true), array($column => array_values($column_data)), array_slice($columns, $offset)); + } } else { -- cgit v1.2.1 From 3cabe5fd792fced4120de02cfef66900b49516c4 Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 26 May 2014 20:47:19 +0200 Subject: [ticket/12561] Added tests for "after last", "after missing" and "empty" Also removed tabs PHPBB3-12561 --- phpBB/phpbb/db/migration/schema_generator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/db/migration/schema_generator.php b/phpBB/phpbb/db/migration/schema_generator.php index f36e6a96d5..18c99fb94a 100644 --- a/phpBB/phpbb/db/migration/schema_generator.php +++ b/phpBB/phpbb/db/migration/schema_generator.php @@ -112,8 +112,8 @@ class schema_generator $columns = $this->tables[$table]['COLUMNS']; $offset = array_search($column_data['after'], array_keys($columns)); unset($column_data['after']); - - if ($offset == false) + + if ($offset === false) { $this->tables[$table]['COLUMNS'][$column] = array_values($column_data); } -- cgit v1.2.1