diff options
author | Nathan Guse <nathaniel.guse@gmail.com> | 2013-02-28 09:52:23 -0600 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-02-28 09:52:23 -0600 |
commit | f665a4b5cfc5db317e04ff387d24c8a7553a3849 (patch) | |
tree | bf5c25518085cf20c90c82849475ee9dfa0cf522 /phpBB/includes | |
parent | c6aabab03961cbfc3d96ef12e91fb65dbc367c16 (diff) | |
parent | 0808e08c0b9c1f6baf80365341385e06a1d35d0f (diff) | |
download | forums-f665a4b5cfc5db317e04ff387d24c8a7553a3849.tar forums-f665a4b5cfc5db317e04ff387d24c8a7553a3849.tar.gz forums-f665a4b5cfc5db317e04ff387d24c8a7553a3849.tar.bz2 forums-f665a4b5cfc5db317e04ff387d24c8a7553a3849.tar.xz forums-f665a4b5cfc5db317e04ff387d24c8a7553a3849.zip |
Merge branch 'develop' of github.com:phpbb/phpbb3 into ticket/11103
# By Nathaniel Guse
# Via David King (2) and Nathaniel Guse (1)
* 'develop' of github.com:phpbb/phpbb3:
[ticket/11370] Effectively installed migrations not inserted into table
[ticket/11369] Reverting migration throws error
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/db/migrator.php | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 74f71775f3..89b253bc8c 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -332,7 +332,6 @@ class phpbb_db_migrator if (!isset($this->migration_state[$name])) { $state['migration_start_time'] = time(); - $this->insert_migration($name, $state); } } @@ -361,14 +360,7 @@ class phpbb_db_migrator } } - $insert = $state; - $insert['migration_depends_on'] = serialize($state['migration_depends_on']); - $sql = 'UPDATE ' . $this->migrations_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $insert) . " - WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - - $this->migration_state[$name] = $state; + $this->insert_migration($name, $state); return true; } @@ -434,20 +426,13 @@ class phpbb_db_migrator } else { - $result = $this->process_data_step($migration->revert_data(), $state['migration_data_state'], false); + $result = $this->process_data_step($migration->revert_data(), '', false); $state['migration_data_state'] = ($result === true) ? '' : $result; $state['migration_data_done'] = ($result === true) ? false : true; } - $insert = $state; - $insert['migration_depends_on'] = serialize($state['migration_depends_on']); - $sql = 'UPDATE ' . $this->migrations_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $insert) . " - WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); - - $this->migration_state[$name] = $state; + $this->insert_migration($name, $state); } else { @@ -660,7 +645,7 @@ class phpbb_db_migrator } /** - * Insert migration row into the database + * Insert/Update migration row into the database * * @param string $name Name of the migration * @param array $state @@ -669,12 +654,22 @@ class phpbb_db_migrator protected function insert_migration($name, $state) { $migration_row = $state; - $migration_row['migration_name'] = $name; $migration_row['migration_depends_on'] = serialize($state['migration_depends_on']); - $sql = 'INSERT INTO ' . $this->migrations_table . ' - ' . $this->db->sql_build_array('INSERT', $migration_row); - $this->db->sql_query($sql); + if (isset($this->migration_state[$name])) + { + $sql = 'UPDATE ' . $this->migrations_table . ' + SET ' . $this->db->sql_build_array('UPDATE', $migration_row) . " + WHERE migration_name = '" . $this->db->sql_escape($name) . "'"; + $this->db->sql_query($sql); + } + else + { + $migration_row['migration_name'] = $name; + $sql = 'INSERT INTO ' . $this->migrations_table . ' + ' . $this->db->sql_build_array('INSERT', $migration_row); + $this->db->sql_query($sql); + } $this->migration_state[$name] = $state; } |