mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
Merge pull request #6524 from marc1706/ticket/17129
[ticket/17129] Use sql_build_array for cleaner update of youtube profile field
This commit is contained in:
commit
bdbbc63b9c
2 changed files with 34 additions and 35 deletions
|
@ -48,19 +48,18 @@ class profilefield_youtube_update extends \phpbb\db\migration\migration
|
|||
$profile_fields = $this->table_prefix . 'profile_fields';
|
||||
$profile_fields_data = $this->table_prefix . 'profile_fields_data';
|
||||
|
||||
$field_validation = $this->db->sql_escape(self::$youtube_url_matcher);
|
||||
$field_data = [
|
||||
'field_length' => 40,
|
||||
'field_minlen' => strlen('https://youtube.com/c/') + 1,
|
||||
'field_maxlen' => 255,
|
||||
'field_validation' => self::$youtube_url_matcher,
|
||||
'field_contact_url' => '%s'
|
||||
];
|
||||
|
||||
$min_length = strlen('https://youtube.com/c/') + 1;
|
||||
|
||||
$this->db->sql_query(
|
||||
"UPDATE $profile_fields SET
|
||||
field_length = '40',
|
||||
field_minlen = '$min_length',
|
||||
field_maxlen = '255',
|
||||
field_validation = '$field_validation',
|
||||
field_contact_url = '%s'
|
||||
WHERE field_name = 'phpbb_youtube'"
|
||||
);
|
||||
$sql = 'UPDATE ' . $profile_fields . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $field_data) . "
|
||||
WHERE field_name = 'phpbb_youtube'";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
$yt_profile_field = 'pf_phpbb_youtube';
|
||||
$prepend_legacy_youtube_url = $this->db->sql_concatenate(
|
||||
|
|
|
@ -70,18 +70,19 @@ class profilefields_update extends \phpbb\db\migration\migration
|
|||
$profile_fields_data = $this->table_prefix . 'profile_fields_data';
|
||||
$end_time = time() + 5; // allow up to 5 seconds for migration to run
|
||||
|
||||
$field_validation = $this->db->sql_escape($this->youtube_url_matcher);
|
||||
$field_data = [
|
||||
'field_length' => 20,
|
||||
'field_minlen' => 3,
|
||||
'field_maxlen' => 60,
|
||||
'field_validation' => $this->youtube_url_matcher,
|
||||
'field_contact_url' => 'https://youtube.com/%s',
|
||||
'field_contact_desc' => 'VIEW_YOUTUBE_PROFILE',
|
||||
];
|
||||
|
||||
$this->db->sql_query(
|
||||
"UPDATE $profile_fields
|
||||
SET field_length = '20',
|
||||
field_minlen = '3',
|
||||
field_maxlen = '60',
|
||||
field_validation = '$field_validation',
|
||||
field_contact_url = 'https://youtube.com/%s'
|
||||
field_contact_desc = 'VIEW_YOUTUBE_PROFILE'
|
||||
WHERE field_name = 'phpbb_youtube'"
|
||||
);
|
||||
$sql = 'UPDATE ' . $profile_fields . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $field_data) . "
|
||||
WHERE field_name = 'phpbb_youtube'";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
$yt_profile_field = 'pf_phpbb_youtube';
|
||||
$has_youtube_url = $this->db->sql_like_expression($this->db->get_any_char() . 'youtube.com/' . $this->db->get_any_char());
|
||||
|
@ -138,19 +139,18 @@ class profilefields_update extends \phpbb\db\migration\migration
|
|||
$profile_fields = $this->table_prefix . 'profile_fields';
|
||||
$profile_fields_data = $this->table_prefix . 'profile_fields_data';
|
||||
|
||||
$old_field_validation = $this->db->sql_escape(profilefield_youtube_update::$youtube_url_matcher);
|
||||
$field_data = [
|
||||
'field_length' => 40,
|
||||
'field_minlen' => strlen('https://youtube.com/c/') + 1,
|
||||
'field_maxlen' => 255,
|
||||
'field_validation' => profilefield_youtube_update::$youtube_url_matcher,
|
||||
'field_contact_url' => '%s'
|
||||
];
|
||||
|
||||
$min_length = strlen('https://youtube.com/c/') + 1;
|
||||
|
||||
$this->db->sql_query(
|
||||
"UPDATE $profile_fields SET
|
||||
field_length = '40',
|
||||
field_minlen = '$min_length',
|
||||
field_maxlen = '255',
|
||||
field_validation = '$old_field_validation',
|
||||
field_contact_url = '%s'
|
||||
WHERE field_name = 'phpbb_youtube'"
|
||||
);
|
||||
$sql = 'UPDATE ' . $profile_fields . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $field_data) . "
|
||||
WHERE field_name = 'phpbb_youtube'";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
$yt_profile_field = 'pf_phpbb_youtube';
|
||||
$prepend_legacy_youtube_url = $this->db->sql_concatenate(
|
||||
|
|
Loading…
Add table
Reference in a new issue