From bd55fe7e8ca7052e5e7ee4b3fccce30891615839 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 16 Apr 2023 10:01:45 +0200 Subject: [PATCH 1/4] [ticket/17129] Update youtube profile field to be up to date with migrations PHPBB3-17129 --- phpBB/install/schemas/schema_data.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 6e0b4117c7..c19ff18985 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -837,7 +837,7 @@ INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_len INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_facebook', 'profilefields.type.string', 'phpbb_facebook', '20', '5', '50', '', '', '[\w.]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 9, 1, 'VIEW_FACEBOOK_PROFILE', 'http://facebook.com/%s/'); INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_twitter', 'profilefields.type.string', 'phpbb_twitter', '20', '1', '15', '', '', '[\w_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 10, 1, 'VIEW_TWITTER_PROFILE', 'http://twitter.com/%s'); INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_skype', 'profilefields.type.string', 'phpbb_skype', '20', '6', '32', '', '', '[a-zA-Z][\w\.,\-_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 11, 1, 'VIEW_SKYPE_PROFILE', 'skype:%s?userinfo'); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_youtube', 'profilefields.type.string', 'phpbb_youtube', '20', '3', '60', '', '', '[a-zA-Z][\w\.,\-_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 12, 1, 'VIEW_YOUTUBE_CHANNEL', 'http://youtube.com/user/%s'); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_youtube', 'profilefields.type.string', 'phpbb_youtube', '40', '23', '255', '', '', 'https:\/\/(www\.)?youtube\.com\/.+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 12, 1, 'VIEW_YOUTUBE_CHANNEL', '%s'); # User Notification Options (for first user) INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('notification.type.post', 0, 2, 'notification.method.board'); From 6e77ca50ae34d487446343e2abecae6ff82c96ef Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 17 Apr 2023 20:37:50 +0200 Subject: [PATCH 2/4] [ticket/17129] Update social media profile types to support latest URLs PHPBB3-17129 --- phpBB/install/schemas/schema_data.sql | 6 +- .../data/v33x/profilefield_youtube_update.php | 6 +- .../data/v33x/profilefields_update.php | 190 ++++++++++++++++++ 3 files changed, 196 insertions(+), 6 deletions(-) create mode 100644 phpBB/phpbb/db/migration/data/v33x/profilefields_update.php diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index c19ff18985..e202bcd82d 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -834,10 +834,10 @@ INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_len INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_occupation', 'profilefields.type.text', 'phpbb_occupation', '3|30', '2', '500', '', '', '.*', 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 4, 0, '', ''); INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_icq', 'profilefields.type.string', 'phpbb_icq', '20', '3', '15', '', '', '[0-9]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 6, 1, 'SEND_ICQ_MESSAGE', 'https://www.icq.com/people/%s/'); INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_yahoo', 'profilefields.type.string', 'phpbb_yahoo', '40', '5', '255', '', '', '.*', 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 8, 1, 'SEND_YIM_MESSAGE', 'ymsgr:sendim?%s'); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_facebook', 'profilefields.type.string', 'phpbb_facebook', '20', '5', '50', '', '', '[\w.]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 9, 1, 'VIEW_FACEBOOK_PROFILE', 'http://facebook.com/%s/'); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_twitter', 'profilefields.type.string', 'phpbb_twitter', '20', '1', '15', '', '', '[\w_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 10, 1, 'VIEW_TWITTER_PROFILE', 'http://twitter.com/%s'); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_facebook', 'profilefields.type.string', 'phpbb_facebook', '20', '5', '50', '', '', '[\w.]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 9, 1, 'VIEW_FACEBOOK_PROFILE', 'https://facebook.com/%s/'); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_twitter', 'profilefields.type.string', 'phpbb_twitter', '20', '1', '15', '', '', '[\w_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 10, 1, 'VIEW_TWITTER_PROFILE', 'https://twitter.com/%s'); INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_skype', 'profilefields.type.string', 'phpbb_skype', '20', '6', '32', '', '', '[a-zA-Z][\w\.,\-_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 11, 1, 'VIEW_SKYPE_PROFILE', 'skype:%s?userinfo'); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_youtube', 'profilefields.type.string', 'phpbb_youtube', '40', '23', '255', '', '', 'https:\/\/(www\.)?youtube\.com\/.+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 12, 1, 'VIEW_YOUTUBE_CHANNEL', '%s'); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_youtube', 'profilefields.type.string', 'phpbb_youtube', '40', '23', '255', '', '', '(@[a-zA-Z0-9_.-]{3,30}|c/[a-zA-Z][\w\.,\-_]+|channel/[a-zA-Z][\w\.,\-_]+)', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 12, 1, 'VIEW_YOUTUBE_CHANNEL', '%s'); # User Notification Options (for first user) INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('notification.type.post', 0, 2, 'notification.method.board'); diff --git a/phpBB/phpbb/db/migration/data/v33x/profilefield_youtube_update.php b/phpBB/phpbb/db/migration/data/v33x/profilefield_youtube_update.php index 232e3b486f..bcf097609a 100644 --- a/phpBB/phpbb/db/migration/data/v33x/profilefield_youtube_update.php +++ b/phpBB/phpbb/db/migration/data/v33x/profilefield_youtube_update.php @@ -15,7 +15,7 @@ namespace phpbb\db\migration\data\v33x; class profilefield_youtube_update extends \phpbb\db\migration\migration { - protected $youtube_url_matcher = 'https:\\/\\/(www\\.)?youtube\\.com\\/.+'; + public static $youtube_url_matcher = 'https:\\/\\/(www\\.)?youtube\\.com\\/.+'; public function effectively_installed() { @@ -30,7 +30,7 @@ class profilefield_youtube_update extends \phpbb\db\migration\migration $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); - return !$row || $row['field_validation'] === $this->youtube_url_matcher; + return !$row || $row['field_validation'] === self::$youtube_url_matcher; } public static function depends_on() @@ -48,7 +48,7 @@ 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($this->youtube_url_matcher); + $field_validation = $this->db->sql_escape(self::$youtube_url_matcher); $min_length = strlen('https://youtube.com/c/') + 1; diff --git a/phpBB/phpbb/db/migration/data/v33x/profilefields_update.php b/phpBB/phpbb/db/migration/data/v33x/profilefields_update.php new file mode 100644 index 0000000000..eb3e7acaa8 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v33x/profilefields_update.php @@ -0,0 +1,190 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v33x; + +class profilefields_update extends \phpbb\db\migration\migration +{ + /** @var string YouTube URLs matcher: handle or custom URL or channel URL */ + protected $youtube_url_matcher = '(@[a-zA-Z0-9_.-]{3,30}|c/[a-zA-Z][\w\.,\-_]+|channel/[a-zA-Z][\w\.,\-_]+)'; + + public static function depends_on(): array + { + return ['\phpbb\db\migration\data\v33x\v3310']; + } + + public function update_schema(): array + { + return [ + 'change_columns' => [ + $this->table_prefix . 'profile_fields' => [ + 'field_validation' => ['VCHAR_UNI:128', ''], + ], + ] + ]; + } + + public function revert_schema(): array + { + return [ + 'change_columns' => [ + $this->table_prefix . 'profile_fields' => [ + 'field_validation' => ['VCHAR_UNI:64', ''], + ], + ] + ]; + } + + public function update_data(): array + { + return [ + ['custom', [[$this, 'update_youtube_profile_field']]], + ['custom', [[$this, 'update_other_profile_fields']]], + ]; + } + + public function revert_data(): array + { + return [ + ['custom', [[$this, 'revert_youtube_profile_field']]], + ['custom', [[$this, 'revert_other_profile_fields']]], + ]; + } + + public function update_youtube_profile_field(): bool + { + $profile_fields = $this->table_prefix . 'profile_fields'; + $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); + + $this->db->sql_query( + "UPDATE $profile_fields + SET field_length = '20', + field_minlen = '3', + field_maxlen = '60', + field_validation = '$field_validation', + field_contact_url = '%s' + WHERE field_name = 'phpbb_youtube'" + ); + + $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()); + + $update_aborted = false; + + $sql = 'SELECT user_id, pf_phpbb_youtube + FROM ' . $profile_fields_data . " + WHERE $yt_profile_field <> '' + AND $yt_profile_field $has_youtube_url"; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $updated_youtube_url_part = $this->get_youtube_url_part($row['pf_phpbb_youtube']); + if ($updated_youtube_url_part != $row['pf_phpbb_youtube']) + { + $this->db->sql_query( + "UPDATE $profile_fields_data + SET $yt_profile_field = '$updated_youtube_url_part' + WHERE user_id = {$row['user_id']}" + ); + } + + if (time() > $end_time) + { + $update_aborted = true; + break; + } + } + $this->db->sql_freeresult($result); + + return $update_aborted != true; + } + + public function update_other_profile_fields(): void + { + $profile_fields = $this->table_prefix . 'profile_fields'; + + $this->db->sql_query( + "UPDATE $profile_fields + SET field_contact_url = 'https://facebook.com/%s/' + WHERE field_name = 'phpbb_facebook'" + ); + + $this->db->sql_query( + "UPDATE $profile_fields + SET field_contact_url = 'https://twitter.com/%s' + WHERE field_name = 'phpbb_twitter'" + ); + } + + public function revert_youtube_profile_field(): void + { + $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); + + $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'" + ); + + $yt_profile_field = 'pf_phpbb_youtube'; + $prepend_legacy_youtube_url = $this->db->sql_concatenate( + "'https://youtube.com/'", $yt_profile_field + ); + $is_not_already_youtube_url = $this->db->sql_not_like_expression( + $this->db->get_any_char() + . 'youtube.com/' + . $this->db->get_any_char() + ); + + $this->db->sql_query( + "UPDATE $profile_fields_data SET + $yt_profile_field = $prepend_legacy_youtube_url + WHERE $yt_profile_field <> '' + AND $yt_profile_field $is_not_already_youtube_url" + ); + } + + public function revert_other_profile_fields(): void + { + $profile_fields = $this->table_prefix . 'profile_fields'; + + $this->db->sql_query( + "UPDATE $profile_fields + SET field_contact_url = 'http://facebook.com/%s/' + WHERE field_name = 'phpbb_facebook'" + ); + + $this->db->sql_query( + "UPDATE $profile_fields + SET field_contact_url = 'http://twitter.com/%s' + WHERE field_name = 'phpbb_twitter'" + ); + } + + protected function get_youtube_url_part(string $profile_field_string): string + { + return preg_replace('#^https://(?:www\.)?youtube\.com/(.+)$#iu', '$1', $profile_field_string); + } +} From 437839ba722cedd94a888465bdaac1a90c1b5be4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 26 Apr 2023 20:54:24 +0200 Subject: [PATCH 3/4] [ticket/17129] Update contact url template PHPBB3-17129 --- phpBB/phpbb/db/migration/data/v33x/profilefields_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/db/migration/data/v33x/profilefields_update.php b/phpBB/phpbb/db/migration/data/v33x/profilefields_update.php index eb3e7acaa8..d7868dfcb7 100644 --- a/phpBB/phpbb/db/migration/data/v33x/profilefields_update.php +++ b/phpBB/phpbb/db/migration/data/v33x/profilefields_update.php @@ -75,7 +75,7 @@ class profilefields_update extends \phpbb\db\migration\migration field_minlen = '3', field_maxlen = '60', field_validation = '$field_validation', - field_contact_url = '%s' + field_contact_url = 'https://youtube.com/%s' WHERE field_name = 'phpbb_youtube'" ); From acaec9f95f3b94d81a697f14c2b56308492c1017 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 20 Jun 2023 10:32:48 +0200 Subject: [PATCH 4/4] [ticket/17129] Update regex and tests for changed input data to youtube cpf PHPBB3-17129 --- phpBB/install/schemas/schema_data.sql | 2 +- phpBB/language/en/memberlist.php | 2 +- .../db/migration/data/v33x/profilefields_update.php | 8 ++++++-- tests/functional/ucp_profile_test.php | 9 +++++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index e202bcd82d..48270b4a1e 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -837,7 +837,7 @@ INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_len INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_facebook', 'profilefields.type.string', 'phpbb_facebook', '20', '5', '50', '', '', '[\w.]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 9, 1, 'VIEW_FACEBOOK_PROFILE', 'https://facebook.com/%s/'); INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_twitter', 'profilefields.type.string', 'phpbb_twitter', '20', '1', '15', '', '', '[\w_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 10, 1, 'VIEW_TWITTER_PROFILE', 'https://twitter.com/%s'); INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_skype', 'profilefields.type.string', 'phpbb_skype', '20', '6', '32', '', '', '[a-zA-Z][\w\.,\-_]+', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 11, 1, 'VIEW_SKYPE_PROFILE', 'skype:%s?userinfo'); -INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_youtube', 'profilefields.type.string', 'phpbb_youtube', '40', '23', '255', '', '', '(@[a-zA-Z0-9_.-]{3,30}|c/[a-zA-Z][\w\.,\-_]+|channel/[a-zA-Z][\w\.,\-_]+)', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 12, 1, 'VIEW_YOUTUBE_CHANNEL', '%s'); +INSERT INTO phpbb_profile_fields (field_name, field_type, field_ident, field_length, field_minlen, field_maxlen, field_novalue, field_default_value, field_validation, field_required, field_show_novalue, field_show_on_reg, field_show_on_pm, field_show_on_vt, field_show_on_ml, field_show_profile, field_hide, field_no_view, field_active, field_order, field_is_contact, field_contact_desc, field_contact_url) VALUES ('phpbb_youtube', 'profilefields.type.string', 'phpbb_youtube', '20', '3', '60', '', '', '(@[a-zA-Z0-9_.-]{3,30}|c/[a-zA-Z][\w\.,\-_]+|(channel|user)/[a-zA-Z][\w\.,\-_]+)', 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 12, 1, 'VIEW_YOUTUBE_PROFILE', 'https://youtube.com/%s'); # User Notification Options (for first user) INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('notification.type.post', 0, 2, 'notification.method.board'); diff --git a/phpBB/language/en/memberlist.php b/phpBB/language/en/memberlist.php index cb48184e55..2e757043bb 100644 --- a/phpBB/language/en/memberlist.php +++ b/phpBB/language/en/memberlist.php @@ -149,5 +149,5 @@ $lang = array_merge($lang, array( 'VIEW_FACEBOOK_PROFILE' => 'View Facebook Profile', 'VIEW_SKYPE_PROFILE' => 'View Skype Profile', 'VIEW_TWITTER_PROFILE' => 'View Twitter Profile', - 'VIEW_YOUTUBE_CHANNEL' => 'View YouTube Channel', + 'VIEW_YOUTUBE_PROFILE' => 'View YouTube Profile', )); diff --git a/phpBB/phpbb/db/migration/data/v33x/profilefields_update.php b/phpBB/phpbb/db/migration/data/v33x/profilefields_update.php index d7868dfcb7..722a962d73 100644 --- a/phpBB/phpbb/db/migration/data/v33x/profilefields_update.php +++ b/phpBB/phpbb/db/migration/data/v33x/profilefields_update.php @@ -16,11 +16,14 @@ namespace phpbb\db\migration\data\v33x; class profilefields_update extends \phpbb\db\migration\migration { /** @var string YouTube URLs matcher: handle or custom URL or channel URL */ - protected $youtube_url_matcher = '(@[a-zA-Z0-9_.-]{3,30}|c/[a-zA-Z][\w\.,\-_]+|channel/[a-zA-Z][\w\.,\-_]+)'; + protected $youtube_url_matcher = '(@[a-zA-Z0-9_.-]{3,30}|c/[a-zA-Z][\w\.,\-_]+|(channel|user)/[a-zA-Z][\w\.,\-_]+)'; public static function depends_on(): array { - return ['\phpbb\db\migration\data\v33x\v3310']; + return [ + '\phpbb\db\migration\data\v33x\v3310', + '\phpbb\db\migration\data\v33x\profilefield_youtube_update', + ]; } public function update_schema(): array @@ -76,6 +79,7 @@ class profilefields_update extends \phpbb\db\migration\migration 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'" ); diff --git a/tests/functional/ucp_profile_test.php b/tests/functional/ucp_profile_test.php index 18839a5a68..d3e95c0aee 100644 --- a/tests/functional/ucp_profile_test.php +++ b/tests/functional/ucp_profile_test.php @@ -19,6 +19,7 @@ class phpbb_functional_ucp_profile_test extends phpbb_functional_test_case public function test_submitting_profile_info() { $this->add_lang('ucp'); + $this->add_lang('memberlist'); $this->login(); $crawler = self::request('GET', 'ucp.php?i=ucp_profile&mode=profile_info'); @@ -29,7 +30,7 @@ class phpbb_functional_ucp_profile_test extends phpbb_functional_test_case 'pf_phpbb_location' => 'Bertie“s Empire', 'pf_phpbb_skype' => 'phpbb.skype.account', 'pf_phpbb_twitter' => 'phpbb_twitter', - 'pf_phpbb_youtube' => 'phpbb.youtube', + 'pf_phpbb_youtube' => 'user/phpbb.youtube', )); $crawler = self::submit($form); @@ -42,7 +43,11 @@ class phpbb_functional_ucp_profile_test extends phpbb_functional_test_case $this->assertEquals('Bertie“s Empire', $form->get('pf_phpbb_location')->getValue()); $this->assertEquals('phpbb.skype.account', $form->get('pf_phpbb_skype')->getValue()); $this->assertEquals('phpbb_twitter', $form->get('pf_phpbb_twitter')->getValue()); - $this->assertEquals('phpbb.youtube', $form->get('pf_phpbb_youtube')->getValue()); + $this->assertEquals('user/phpbb.youtube', $form->get('pf_phpbb_youtube')->getValue()); + + $crawler = self::request('GET', 'memberlist.php?mode=viewprofile&un=admin'); + $link = $crawler->selectLink($this->lang('VIEW_YOUTUBE_PROFILE')); + $this->assertSame('https://youtube.com/user/phpbb.youtube', $link->attr('href')); } public function test_submitting_emoji()