aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/db
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-11-25 13:12:08 +0100
committerMarc Alexander <admin@m-a-styles.de>2013-11-25 13:12:08 +0100
commit0d4bf3ff45a76dcb763c76502944aa7bf78b690b (patch)
tree206b50135b4dae284033adf79143f00279c28a5e /phpBB/phpbb/db
parentb5e6d107aea96aa3338584b5f8027eade9b68f99 (diff)
downloadforums-0d4bf3ff45a76dcb763c76502944aa7bf78b690b.tar
forums-0d4bf3ff45a76dcb763c76502944aa7bf78b690b.tar.gz
forums-0d4bf3ff45a76dcb763c76502944aa7bf78b690b.tar.bz2
forums-0d4bf3ff45a76dcb763c76502944aa7bf78b690b.tar.xz
forums-0d4bf3ff45a76dcb763c76502944aa7bf78b690b.zip
[ticket/11842] Use type map for updating avatar types in database
PHPBB3-11842
Diffstat (limited to 'phpBB/phpbb/db')
-rw-r--r--phpBB/phpbb/db/migration/data/v310/avatar_types.php51
1 files changed, 23 insertions, 28 deletions
diff --git a/phpBB/phpbb/db/migration/data/v310/avatar_types.php b/phpBB/phpbb/db/migration/data/v310/avatar_types.php
index 439e20889c..5750a43ddd 100644
--- a/phpBB/phpbb/db/migration/data/v310/avatar_types.php
+++ b/phpBB/phpbb/db/migration/data/v310/avatar_types.php
@@ -11,6 +11,15 @@ namespace phpbb\db\migration\data\v310;
class avatar_types extends \phpbb\db\migration\migration
{
+ /**
+ * @var avatar type map
+ */
+ protected $avatar_type_map = array(
+ AVATAR_UPLOAD => 'avatar.driver.upload',
+ AVATAR_REMOTE => 'avatar.driver.remote',
+ AVATAR_GALLERY => 'avatar.driver.local',
+ );
+
static public function depends_on()
{
return array(
@@ -29,37 +38,23 @@ class avatar_types extends \phpbb\db\migration\migration
public function update_user_avatar_type()
{
- $sql = 'UPDATE ' . $this->table_prefix . "users
- SET user_avatar_type = 'avatar.driver.upload'
- WHERE user_avatar_type = " . AVATAR_UPLOAD;
- $this->db->sql_query($sql);
-
- $sql = 'UPDATE ' . $this->table_prefix . "users
- SET user_avatar_type = 'avatar.driver.remote'
- WHERE user_avatar_type = " . AVATAR_REMOTE;
- $this->db->sql_query($sql);
-
- $sql = 'UPDATE ' . $this->table_prefix . "users
- SET user_avatar_type = 'avatar.driver.local'
- WHERE user_avatar_type = " . AVATAR_GALLERY;
- $this->db->sql_query($sql);
+ foreach ($this->avatar_type_map as $old => $new)
+ {
+ $sql = 'UPDATE ' . $this->table_prefix . "users
+ SET user_avatar_type = '$new'
+ WHERE user_avatar_type = $old";
+ $this->db->sql_query($sql);
+ }
}
public function update_group_avatar_type()
{
- $sql = 'UPDATE ' . $this->table_prefix . "groups
- SET group_avatar_type = 'avatar.driver.upload'
- WHERE group_avatar_type = " . AVATAR_UPLOAD;
- $this->db->sql_query($sql);
-
- $sql = 'UPDATE ' . $this->table_prefix . "groups
- SET group_avatar_type = 'avatar.driver.remote'
- WHERE group_avatar_type = " . AVATAR_REMOTE;
- $this->db->sql_query($sql);
-
- $sql = 'UPDATE ' . $this->table_prefix . "groups
- SET group_avatar_type = 'avatar.driver.local'
- WHERE group_avatar_type = " . AVATAR_GALLERY;
- $this->db->sql_query($sql);
+ foreach ($this->avatar_type_map as $old => $new)
+ {
+ $sql = 'UPDATE ' . $this->table_prefix . "groups
+ SET group_avatar_type = '$new'
+ WHERE group_avatar_type = $old";
+ $this->db->sql_query($sql);
+ }
}
}