From 6045aa7aa2fb63358e3f736504b17533b1085712 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 25 Feb 2013 19:16:29 -0600 Subject: [PATCH 1/2] [ticket/11367] Migrator throws error if migrations table does not exist Force load_migration_state to not throw errors if the table does not exist. PHPBB3-11367 --- phpBB/includes/db/migrator.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 41d996b1e3..ea5de3372f 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -99,18 +99,26 @@ class phpbb_db_migrator { $this->migration_state = array(); + // prevent errors in case the table does not exist yet + $this->db->sql_return_on_error(true); + $sql = "SELECT * FROM " . $this->migrations_table; $result = $this->db->sql_query($sql); - while ($migration = $this->db->sql_fetchrow($result)) + if (!$this->db->sql_error_triggered) { - $this->migration_state[$migration['migration_name']] = $migration; + while ($migration = $this->db->sql_fetchrow($result)) + { + $this->migration_state[$migration['migration_name']] = $migration; - $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); + $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); + } + + $this->db->sql_freeresult($result); } - $this->db->sql_freeresult($result); + $this->db->sql_return_on_error(false); } /** From 9a319fefb2ffed58da1d3339d59e53de09521e03 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 26 Feb 2013 10:22:13 -0600 Subject: [PATCH 2/2] [ticket/11367] Always freeresult PHPBB3-11367 --- phpBB/includes/db/migrator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index ea5de3372f..74f71775f3 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -114,10 +114,10 @@ class phpbb_db_migrator $this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); } - - $this->db->sql_freeresult($result); } + $this->db->sql_freeresult($result); + $this->db->sql_return_on_error(false); }