diff options
author | Nathan Guse <nathaniel.guse@gmail.com> | 2013-01-09 15:41:04 -0600 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-01-09 16:44:09 -0600 |
commit | f56e400cd36b6d17ffde90a91e6e221cb83d2dbd (patch) | |
tree | adeae3a14a47eec4203e26d87c496b3bd595623f /phpBB | |
parent | edf693e3bd4352ab75c62311b34f12fc98e7ef63 (diff) | |
download | forums-f56e400cd36b6d17ffde90a91e6e221cb83d2dbd.tar forums-f56e400cd36b6d17ffde90a91e6e221cb83d2dbd.tar.gz forums-f56e400cd36b6d17ffde90a91e6e221cb83d2dbd.tar.bz2 forums-f56e400cd36b6d17ffde90a91e6e221cb83d2dbd.tar.xz forums-f56e400cd36b6d17ffde90a91e6e221cb83d2dbd.zip |
[feature/migrations] Comments
PHPBB3-9737
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/includes/db/migration/tool/permission.php | 12 | ||||
-rw-r--r-- | phpBB/includes/db/migrator.php | 28 |
2 files changed, 28 insertions, 12 deletions
diff --git a/phpBB/includes/db/migration/tool/permission.php b/phpBB/includes/db/migration/tool/permission.php index 97fdbc0df9..7b45b24361 100644 --- a/phpBB/includes/db/migration/tool/permission.php +++ b/phpBB/includes/db/migration/tool/permission.php @@ -366,7 +366,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte switch ($type) { - case 'role' : + case 'role': $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . " WHERE role_name = '" . $this->db->sql_escape($name) . "'"; @@ -389,7 +389,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $this->db->sql_freeresult($result); break; - case 'group' : + case 'group': $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = '" . $this->db->sql_escape($name) . "'"; @@ -435,7 +435,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $sql_ary = array(); switch ($type) { - case 'role' : + case 'role': foreach ($new_auth as $auth_option_id) { if (!isset($current_auth[$auth_option_id])) @@ -451,7 +451,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $this->db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary); break; - case 'group' : + case 'group': foreach ($new_auth as $auth_option_id) { if (!isset($current_auth[$auth_option_id])) @@ -508,7 +508,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte switch ($type) { - case 'role' : + case 'role': $sql = 'SELECT role_id FROM ' . ACL_ROLES_TABLE . " WHERE role_name = '" . $this->db->sql_escape($name) . "'"; @@ -525,7 +525,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $this->db->sql_query($sql); break; - case 'group' : + case 'group': $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = '" . $this->db->sql_escape($name) . "'"; diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index 7aa4cfa719..5d8dc12f58 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -43,13 +43,27 @@ class phpbb_db_migrator /** @var string */ protected $migrations_table; - /** @var array State of all migrations (SELECT * FROM migrations table) */ - protected $migration_state; + /** + * State of all migrations + * + * (SELECT * FROM migrations table) + * + * @var array + */ + protected $migration_state = array(); - /** @var array Array of all migrations available to be run */ + /** + * Array of all migrations available to be run + * + * @var array + */ protected $migrations = array(); - /** @var array 'name' and 'class' of the last migration run */ + /** + * 'name' and 'class' of the last migration run + * + * @var array + */ public $last_run_migration = false; /** @@ -83,11 +97,12 @@ class phpbb_db_migrator */ public function load_migration_state() { + $this->migration_state = array(); + $sql = "SELECT * FROM " . $this->migrations_table; $result = $this->db->sql_query($sql); - $this->migration_state = array(); while ($migration = $this->db->sql_fetchrow($result)) { $this->migration_state[$migration['migration_name']] = $migration; @@ -137,8 +152,9 @@ class phpbb_db_migrator $added_classes = array_diff(get_declared_classes(), $declared_classes); if ( - // The phpbb_db_migrations class may not have been loaded until now, so make sure to ignore it. + // If two classes have been added and phpbb_db_migration is one of them, we've only added one real migration !(sizeof($added_classes) == 2 && in_array('phpbb_db_migration', $added_classes)) && + // Otherwise there should only be one class added sizeof($added_classes) != 1 ) { |