From da32d51a8161245ce892ca3f45456b1449b246b4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 18 Apr 2025 17:07:42 +0200 Subject: [PATCH] [ticket/17493] Remove remnants of user_notify_type PHPBB-17493 --- phpBB/includes/acp/acp_email.php | 42 +++++----- phpBB/includes/acp/acp_inactive.php | 25 +++--- phpBB/includes/acp/acp_users.php | 2 - phpBB/includes/functions_user.php | 3 +- phpBB/includes/mcp/mcp_reports.php | 2 +- phpBB/includes/ucp/ucp_activate.php | 21 ++--- phpBB/includes/ucp/ucp_prefs.php | 2 - phpBB/includes/ucp/ucp_profile.php | 20 +++-- phpBB/includes/ucp/ucp_resend.php | 23 +++-- .../db/migration/data/v400/remove_jabber.php | 15 ++-- .../data/v400/remove_notify_type.php | 64 ++++++++++++++ phpBB/phpbb/message/admin_form.php | 1 - phpBB/phpbb/message/message.php | 83 +++++++------------ phpBB/phpbb/message/topic_form.php | 1 - phpBB/phpbb/message/user_form.php | 2 +- phpBB/phpbb/ucp/controller/reset_password.php | 4 +- tests/auth/provider_apache_test.php | 1 - tests/functional/user_password_reset_test.php | 2 +- tests/notification/convert_test.php | 22 ++++- tests/notification/fixtures/convert.xml | 7 -- 20 files changed, 190 insertions(+), 152 deletions(-) create mode 100644 phpBB/phpbb/db/migration/data/v400/remove_notify_type.php diff --git a/phpBB/includes/acp/acp_email.php b/phpBB/includes/acp/acp_email.php index 8dbdbf409d..5156676881 100644 --- a/phpBB/includes/acp/acp_email.php +++ b/phpBB/includes/acp/acp_email.php @@ -226,33 +226,29 @@ class acp_email */ foreach ($messenger_collection_iterator as $messenger_method) { - $notify_method = $messenger_method->get_id(); - if ($notify_method == messenger_interface::NOTIFY_EMAIL) + $messenger_method->set_use_queue($use_queue); + $messenger_method->template($email_template, $used_lang); + $messenger_method->subject(html_entity_decode($subject, ENT_COMPAT)); + $messenger_method->assign_vars($template_data); + + for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++) { - $messenger_method->set_use_queue($use_queue); - $messenger_method->template($email_template, $used_lang); - $messenger_method->subject(html_entity_decode($subject, ENT_COMPAT)); - $messenger_method->assign_vars($template_data); - - for ($j = 0, $list_size = count($email_list[$i]); $j < $list_size; $j++) + $email_row = $email_list[$i][$j]; + if (count($email_list[$i]) == 1) { - $email_row = $email_list[$i][$j]; - if (count($email_list[$i]) == 1) - { - $messenger_method->to($email_row['email'], $email_row['name']); - } - else - { - $messenger_method->bcc($email_row['email'], $email_row['name']); - } + $messenger_method->to($email_row['email'], $email_row['name']); + } + else + { + $messenger_method->bcc($email_row['email'], $email_row['name']); } - - $messenger_method->anti_abuse_headers($config, $user); - $messenger_method->set_mail_priority($priority); - - $errored = !$messenger_method->send() || $errored; - $messenger_method->save_queue(); } + + $messenger_method->anti_abuse_headers($config, $user); + $messenger_method->set_mail_priority($priority); + + $errored = !$messenger_method->send() || $errored; + $messenger_method->save_queue(); } } unset($email_list); diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php index 138e06e525..b4b39cbdf9 100644 --- a/phpBB/includes/acp/acp_inactive.php +++ b/phpBB/includes/acp/acp_inactive.php @@ -185,7 +185,7 @@ class acp_inactive trigger_error($user->lang['EMAIL_DISABLED'] . adm_back_link($this->u_action), E_USER_WARNING); } - $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_type, user_regdate, user_actkey + $sql = 'SELECT user_id, username, user_email, user_lang, user_regdate, user_actkey FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $mark) . ' AND user_inactive_reason'; @@ -211,20 +211,17 @@ class acp_inactive */ foreach ($messenger_collection_iterator as $messenger_method) { - if ($messenger_method->get_id() == $user_row['user_notify_type'] || $user_row['user_notify_type'] == $messenger_method::NOTIFY_BOTH) - { - $messenger_method->template('user_remind_inactive', $row['user_lang']); - $messenger_method->set_addresses($row); - $messenger_method->anti_abuse_headers($config, $user); - $messenger_method->assign_vars([ - 'USERNAME' => html_entity_decode($row['username'], ENT_COMPAT), - 'REGISTER_DATE' => $user->format_date($row['user_regdate'], false, true), - 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'], - ]); + $messenger_method->template('user_remind_inactive', $row['user_lang']); + $messenger_method->set_addresses($row); + $messenger_method->anti_abuse_headers($config, $user); + $messenger_method->assign_vars([ + 'USERNAME' => html_entity_decode($row['username'], ENT_COMPAT), + 'REGISTER_DATE' => $user->format_date($row['user_regdate'], false, true), + 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'], + ]); - $messenger_method->send(); - $messenger_method->save_queue(); - } + $messenger_method->send(); + $messenger_method->save_queue(); } $usernames[] = $row['username']; diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index e01eace64e..42d0338ba2 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1577,7 +1577,6 @@ class acp_users 'viewemail' => $request->variable('viewemail', $user_row['user_allow_viewemail']), 'massemail' => $request->variable('massemail', $user_row['user_allow_massemail']), 'hideonline' => $request->variable('hideonline', !$user_row['user_allow_viewonline']), - 'notifymethod' => $request->variable('notifymethod', $user_row['user_notify_type']), 'notifypm' => $request->variable('notifypm', $user_row['user_notify_pm']), 'allowpm' => $request->variable('allowpm', $user_row['user_allow_pm']), @@ -1648,7 +1647,6 @@ class acp_users 'user_allow_viewemail' => $data['viewemail'], 'user_allow_massemail' => $data['massemail'], 'user_allow_viewonline' => !$data['hideonline'], - 'user_notify_type' => $data['notifymethod'], 'user_notify_pm' => $data['notifypm'], 'user_dateformat' => $data['dateformat'], diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 42c9e7fd5a..a408f695aa 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -246,7 +246,6 @@ function user_add($user_row, $cp_data = false, $notifications_data = null) 'user_notify' => 0, 'user_notify_pm' => 1, - 'user_notify_type' => messenger_interface::NOTIFY_EMAIL, 'user_allow_pm' => 1, 'user_allow_viewonline' => 1, 'user_allow_viewemail' => 1, @@ -2528,7 +2527,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna case 'approve': // Make sure we only approve those which are pending ;) - $sql = 'SELECT u.user_id, u.user_email, u.username, u.username_clean, u.user_notify_type, u.user_lang + $sql = 'SELECT u.user_id FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug WHERE ug.group_id = ' . $group_id . ' AND ug.user_pending = 1 diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 3325fd6b8d..ee9be079ae 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -661,7 +661,7 @@ function close_report($report_id_list, $mode, $action, $pm = false) { $post_info = ($pm) ? phpbb_get_pm_data($post_id_list) : phpbb_get_post_data($post_id_list, 'm_report'); - $sql = "SELECT r.report_id, r.$id_column, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_lang, u.user_notify_type + $sql = "SELECT r.report_id, r.$id_column, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_lang FROM " . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . ' ' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . ' diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php index 81036c1956..50ccdfa7e6 100644 --- a/phpBB/includes/ucp/ucp_activate.php +++ b/phpBB/includes/ucp/ucp_activate.php @@ -35,7 +35,7 @@ class ucp_activate $user_id = $request->variable('u', 0); $key = $request->variable('k', ''); - $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason + $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_actkey, user_inactive_reason FROM ' . USERS_TABLE . " WHERE user_id = $user_id"; $result = $db->sql_query($sql); @@ -140,18 +140,15 @@ class ucp_activate */ foreach ($messenger_collection_iterator as $messenger_method) { - if ($messenger_method->get_id() == $user_row['user_notify_type'] || $user_row['user_notify_type'] == $messenger_method::NOTIFY_BOTH) - { - $messenger_method->set_use_queue(false); - $messenger_method->template('admin_welcome_activated', $user_row['user_lang']); - $messenger_method->set_addresses($user_row); - $messenger_method->anti_abuse_headers($config, $user); - $messenger_method->assign_vars([ - 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), - ]); + $messenger_method->set_use_queue(false); + $messenger_method->template('admin_welcome_activated', $user_row['user_lang']); + $messenger_method->set_addresses($user_row); + $messenger_method->anti_abuse_headers($config, $user); + $messenger_method->assign_vars([ + 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), + ]); - $messenger_method->send(); - } + $messenger_method->send(); } $message = 'ACCOUNT_ACTIVE_ADMIN'; diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 480b4a3d12..86440cd714 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -42,7 +42,6 @@ class ucp_prefs case 'personal': add_form_key('ucp_prefs_personal'); $data = array( - 'notifymethod' => $request->variable('notifymethod', $user->data['user_notify_type']), 'dateformat' => $request->variable('dateformat', $user->data['user_dateformat'], true), 'lang' => basename($request->variable('lang', $user->data['user_lang'])), 'user_style' => $request->variable('user_style', (int) $user->data['user_style']), @@ -99,7 +98,6 @@ class ucp_prefs 'user_allow_viewemail' => $data['viewemail'], 'user_allow_massemail' => $data['massemail'], 'user_allow_viewonline' => ($auth->acl_get('u_hideonline')) ? !$data['hideonline'] : $user->data['user_allow_viewonline'], - 'user_notify_type' => $data['notifymethod'], 'user_options' => $user->data['user_options'], 'user_dateformat' => $data['dateformat'], diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 77c1a56e9d..a5a1fe3d70 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -357,9 +357,7 @@ class ucp_profile if (!count($error)) { - $sql_ary = array( - 'user_notify_type' => messenger_interface::NOTIFY_EMAIL, - ); + $sql_ary = []; if ($config['allow_birthdays']) { @@ -378,13 +376,17 @@ class ucp_profile $vars = array('cp_data', 'data', 'sql_ary'); extract($phpbb_dispatcher->trigger_event('core.ucp_profile_info_modify_sql_ary', compact($vars))); - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); + // Skip query if no data to update + if (count($sql_ary)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE user_id = ' . $user->data['user_id']; + $db->sql_query($sql); - // Update Custom Fields - $cp->update_profile_field_data($user->data['user_id'], $cp_data); + // Update Custom Fields + $cp->update_profile_field_data($user->data['user_id'], $cp_data); + } meta_refresh(3, $this->u_action); $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); diff --git a/phpBB/includes/ucp/ucp_resend.php b/phpBB/includes/ucp/ucp_resend.php index d3512865db..023ea80852 100644 --- a/phpBB/includes/ucp/ucp_resend.php +++ b/phpBB/includes/ucp/ucp_resend.php @@ -128,7 +128,7 @@ class ucp_resend // Grab an array of user_id's with a_user permissions ... these users can activate a user $admin_ary = $auth->acl_get_list(false, 'a_user', false); - $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_type + $sql = 'SELECT user_id, username, user_email, user_lang FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']); $result = $db->sql_query($sql); @@ -145,19 +145,16 @@ class ucp_resend foreach ($messenger_collection_iterator as $messenger_method) { $messenger_method->set_use_queue(false); - if ($messenger_method->get_id() == $row['user_notify_type'] || $row['user_notify_type'] == $messenger_method::NOTIFY_BOTH) - { - $messenger_method->template('admin_activate', $row['user_lang']); - $messenger_method->set_addresses($row); - $messenger_method->anti_abuse_headers($config, $user); - $messenger_method->assign_vars([ - 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), - 'U_USER_DETAILS' => $board_url . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}", - 'U_ACTIVATE' => $board_url . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}", - ]); + $messenger_method->template('admin_activate', $row['user_lang']); + $messenger_method->set_addresses($row); + $messenger_method->anti_abuse_headers($config, $user); + $messenger_method->assign_vars([ + 'USERNAME' => html_entity_decode($user_row['username'], ENT_COMPAT), + 'U_USER_DETAILS' => $board_url . "/memberlist.$phpEx?mode=viewprofile&u={$user_row['user_id']}", + 'U_ACTIVATE' => $board_url . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}", + ]); - $messenger_method->send(); - } + $messenger_method->send(); } } $db->sql_freeresult($result); diff --git a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php index 994f8c0167..c297ef0a8a 100644 --- a/phpBB/phpbb/db/migration/data/v400/remove_jabber.php +++ b/phpBB/phpbb/db/migration/data/v400/remove_jabber.php @@ -69,7 +69,7 @@ class remove_jabber extends migration ]], ['permission.remove', ['a_jabber']], ['permission.remove', ['u_sendim']], - ['custom', [[$this, 'remove_from_user_notifcations']]], + ['custom', [[$this, 'move_jabber_to_email_notifications']]], ]; } @@ -101,10 +101,15 @@ class remove_jabber extends migration ]; } - public function remove_from_user_notifcations() + public function move_jabber_to_email_notifications(int $start = 0) { - $sql = 'DELETE FROM ' . $this->table_prefix . 'user_notifications - WHERE notification_method = ' . $this->db->sql_escape('notification.method.jabber'); - $this->db->sql_query($sql); + $limit = 1000; + + $sql = 'UPDATE ' . $this->tables['user_notifications'] . ' + SET ' . $this->db->sql_build_array('UPDATE', ['method' => 'notification.method.email']) . " + WHERE method = 'notification.method.jabber'"; + $this->db->sql_query_limit($sql, $limit, $start); + + return $this->db->sql_affectedrows() < $limit ? true : $start + $limit; } } diff --git a/phpBB/phpbb/db/migration/data/v400/remove_notify_type.php b/phpBB/phpbb/db/migration/data/v400/remove_notify_type.php new file mode 100644 index 0000000000..a4b3cce8ed --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v400/remove_notify_type.php @@ -0,0 +1,64 @@ + + * @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\v400; + +use phpbb\db\migration\migration; + +class remove_notify_type extends migration +{ + public static function depends_on(): array + { + return [ + '\phpbb\db\migration\data\v400\remove_jabber', + '\phpbb\db\migration\data\v400\dev', + '\phpbb\db\migration\data\v30x\release_3_0_0', + ]; + } + + public function update_schema(): array + { + return [ + 'drop_columns' => [ + $this->table_prefix . 'users' => [ + 'user_notify_type', + ], + ] + ]; + } + + public function revert_schema(): array + { + return [ + 'add_columns' => [ + $this->table_prefix . 'users' => [ + 'user_notify_type' => ['TINT:4', 0], + ], + ] + ]; + } + + public function update_data() + { + return [ + ['custom', [[$this, 'remove_jabber_user_notifications']]], + ]; + } + + protected function remove_jabber_user_notifications(): void + { + $sql = 'DELETE FROM ' . $this->tables['user_notifications'] . " + WHERE method = 'notification.method.jabber'"; + $this->db->sql_query($sql); + } +} diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php index 72beaa38a6..e6e64210d8 100644 --- a/phpBB/phpbb/message/admin_form.php +++ b/phpBB/phpbb/message/admin_form.php @@ -157,7 +157,6 @@ class admin_form extends form } $this->message->set_sender($this->user->ip, $this->sender_name, $this->sender_address, $this->user->lang_name); - $this->message->set_sender_notify_type(messenger_interface::NOTIFY_EMAIL); } $this->message->set_template('contact_admin'); diff --git a/phpBB/phpbb/message/message.php b/phpBB/phpbb/message/message.php index 344c2f1cf2..9eae8719a4 100644 --- a/phpBB/phpbb/message/message.php +++ b/phpBB/phpbb/message/message.php @@ -54,9 +54,6 @@ class message /** @var string */ protected $sender_username = ''; - /** @var int */ - protected $sender_notify_type = messenger_interface::NOTIFY_EMAIL; - /** @var array */ protected $recipients; @@ -126,7 +123,6 @@ class message $user['username'], $user['user_email'], $user['user_lang'], - $user['user_notify_type'], $user['username'] ); } @@ -137,18 +133,16 @@ class message * @param string $recipient_name Displayed sender name * @param string $recipient_address Email address * @param string $recipient_lang - * @param int $recipient_notify_type Used notification methods (Jabber, Email, ...) * @param string $recipient_username User Name (used for AntiAbuse header) * @return void */ - public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = messenger_interface::NOTIFY_EMAIL, $recipient_username = '') + public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_username = '') { $this->recipients[] = array( 'name' => $recipient_name, 'user_email' => $recipient_address, 'lang' => $recipient_lang, 'username' => $recipient_username, - 'notify_type' => $recipient_notify_type, 'to_name' => $recipient_name, ); } @@ -169,8 +163,6 @@ class message $user->data['user_id'], $user->data['username'] ); - - $this->set_sender_notify_type($user->data['user_notify_type']); } /** @@ -194,17 +186,6 @@ class message $this->sender_username = $sender_username; } - /** - * Which notification type should be used? Jabber, Email, ...? - * - * @param int $sender_notify_type - * @return void - */ - public function set_sender_notify_type($sender_notify_type) - { - $this->sender_notify_type = $sender_notify_type; - } - /** * Ok, now the same email if CC specified, but without exposing the user's email address * @@ -226,7 +207,6 @@ class message 'user_email' => $this->sender_address, 'name' => $this->sender_name, 'username' => $this->sender_username, - 'notify_type' => $this->sender_notify_type, 'to_name' => $this->recipients[0]['to_name'], ); } @@ -257,40 +237,37 @@ class message foreach ($messenger_collection_iterator as $messenger_method) { $messenger_method->set_use_queue(false); - if ($messenger_method->get_id() == $recipient['notify_type'] || $recipient['notify_type'] == $messenger_method::NOTIFY_BOTH) + $messenger_method->template($this->template, $recipient['lang']); + $messenger_method->set_addresses($recipient); + $messenger_method->reply_to($this->sender_address); + + $messenger_method->header('X-AntiAbuse', 'Board servername - ' . $this->server_name); + $messenger_method->header('X-AntiAbuse', 'User IP - ' . $this->sender_ip); + if ($this->sender_id) { - $messenger_method->template($this->template, $recipient['lang']); - $messenger_method->set_addresses($recipient); - $messenger_method->reply_to($this->sender_address); - - $messenger_method->header('X-AntiAbuse', 'Board servername - ' . $this->server_name); - $messenger_method->header('X-AntiAbuse', 'User IP - ' . $this->sender_ip); - if ($this->sender_id) - { - $messenger_method->header('X-AntiAbuse', 'User_id - ' . $this->sender_id); - } - - if ($this->sender_username) - { - $messenger_method->header('X-AntiAbuse', 'Username - ' . $this->sender_username); - } - - $messenger_method->subject(html_entity_decode($this->subject, ENT_COMPAT)); - - $messenger_method->assign_vars([ - 'BOARD_CONTACT' => $contact, - 'TO_USERNAME' => html_entity_decode($recipient['to_name'], ENT_COMPAT), - 'FROM_USERNAME' => html_entity_decode($this->sender_name, ENT_COMPAT), - 'MESSAGE' => html_entity_decode($this->body, ENT_COMPAT), - ]); - - if (count($this->template_vars)) - { - $messenger_method->assign_vars($this->template_vars); - } - - $messenger_method->send(); + $messenger_method->header('X-AntiAbuse', 'User_id - ' . $this->sender_id); } + + if ($this->sender_username) + { + $messenger_method->header('X-AntiAbuse', 'Username - ' . $this->sender_username); + } + + $messenger_method->subject(html_entity_decode($this->subject, ENT_COMPAT)); + + $messenger_method->assign_vars([ + 'BOARD_CONTACT' => $contact, + 'TO_USERNAME' => html_entity_decode($recipient['to_name'], ENT_COMPAT), + 'FROM_USERNAME' => html_entity_decode($this->sender_name, ENT_COMPAT), + 'MESSAGE' => html_entity_decode($this->body, ENT_COMPAT), + ]); + + if (count($this->template_vars)) + { + $messenger_method->assign_vars($this->template_vars); + } + + $messenger_method->send(); } } } diff --git a/phpBB/phpbb/message/topic_form.php b/phpBB/phpbb/message/topic_form.php index dd73a67ab2..8141a66b62 100644 --- a/phpBB/phpbb/message/topic_form.php +++ b/phpBB/phpbb/message/topic_form.php @@ -134,7 +134,6 @@ class topic_form extends form $this->recipient_lang, messenger_interface::NOTIFY_EMAIL ); - $this->message->set_sender_notify_type(messenger_interface::NOTIFY_EMAIL); parent::submit($messenger); } diff --git a/phpBB/phpbb/message/user_form.php b/phpBB/phpbb/message/user_form.php index f52eabc7e9..69189a81f1 100644 --- a/phpBB/phpbb/message/user_form.php +++ b/phpBB/phpbb/message/user_form.php @@ -34,7 +34,7 @@ class user_form extends form */ protected function get_user_row($user_id) { - $sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang, user_notify_type + $sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang FROM ' . USERS_TABLE . ' WHERE user_id = ' . (int) $user_id . ' AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; diff --git a/phpBB/phpbb/ucp/controller/reset_password.php b/phpBB/phpbb/ucp/controller/reset_password.php index d9ec05316c..790e00138c 100644 --- a/phpBB/phpbb/ucp/controller/reset_password.php +++ b/phpBB/phpbb/ucp/controller/reset_password.php @@ -176,7 +176,7 @@ class reset_password } $sql_array = [ - 'SELECT' => 'user_id, username, user_permissions, user_email, user_notify_type, user_type,' + 'SELECT' => 'user_id, username, user_permissions, user_email, user_type,' . ' user_lang, user_inactive_reason, reset_token, reset_token_expiration', 'FROM' => [$this->users_table => 'u'], 'WHERE' => "user_email = '" . $this->db->sql_escape($email) . "'" . @@ -308,7 +308,7 @@ class reset_password add_form_key('ucp_reset_password'); $sql_array = [ - 'SELECT' => 'user_id, username, user_permissions, user_email, user_notify_type, user_type,' + 'SELECT' => 'user_id, username, user_permissions, user_email, user_type,' . ' user_lang, user_inactive_reason, reset_token, reset_token_expiration', 'FROM' => [$this->users_table => 'u'], 'WHERE' => 'user_id = ' . $user_id, diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index 3604bbf9cd..2fcb5b8484 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -152,7 +152,6 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case 'user_post_sortby_dir' => 'a', 'user_notify' => 0, 'user_notify_pm' => 1, - 'user_notify_type' => 0, 'user_allow_pm' => 1, 'user_allow_viewonline' => 1, 'user_allow_viewemail' => 1, diff --git a/tests/functional/user_password_reset_test.php b/tests/functional/user_password_reset_test.php index 7e15aca56f..cf0f903817 100644 --- a/tests/functional/user_password_reset_test.php +++ b/tests/functional/user_password_reset_test.php @@ -263,7 +263,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca protected function get_user_data($username) { $db = $this->get_db(); - $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason, reset_token, reset_token_expiration + $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_actkey, user_inactive_reason, reset_token, reset_token_expiration FROM ' . USERS_TABLE . " WHERE username = '" . $db->sql_escape($username) . "'"; $result = $db->sql_query($sql); diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php index 0def0be5ed..6c1f7b496e 100644 --- a/tests/notification/convert_test.php +++ b/tests/notification/convert_test.php @@ -30,15 +30,33 @@ class phpbb_notification_convert_test extends phpbb_database_test_case $this->db = $this->new_dbal(); $this->doctrine_db = $this->new_doctrine_dbal(); $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($this->doctrine_db); + $core_tables = self::get_core_tables(); + + // Add user_notify_type column for testing this migration and set type + $db_tools->sql_column_add($core_tables['users'], 'user_notify_type', ['TINT:4', 0]); + $user_notify_type_map = [ + 1 => 0, + 2 => 0, + 3 => 1, + 4 => 1, + 5 => 2, + 6 => 2, + ]; + + foreach ($user_notify_type_map as $user_id => $notify_type) + { + $this->db->sql_query('UPDATE ' . $core_tables['users'] . ' SET user_notify_type = ' . (int) $notify_type . ' WHERE user_id = ' . (int) $user_id); + } $this->migration = new \phpbb\db\migration\data\v310\notification_options_reconvert( new \phpbb\config\config(array()), $this->db, - $factory->get($this->doctrine_db), + $db_tools, $phpbb_root_path, $phpEx, 'phpbb_', - self::get_core_tables() + $core_tables ); } diff --git a/tests/notification/fixtures/convert.xml b/tests/notification/fixtures/convert.xml index c9d8fafa97..9b357504d1 100644 --- a/tests/notification/fixtures/convert.xml +++ b/tests/notification/fixtures/convert.xml @@ -4,7 +4,6 @@ user_id username username_clean - user_notify_type user_notify_pm user_permissions user_sig @@ -13,7 +12,6 @@ 1 1 0 - 0 @@ -21,7 +19,6 @@ 2 2 2 - 0 1 @@ -30,7 +27,6 @@ 3 3 3 - 1 0 @@ -40,7 +36,6 @@ 4 4 1 - 1 @@ -48,7 +43,6 @@ 5 5 5 - 2 0 @@ -57,7 +51,6 @@ 6 6 6 - 2 1