diff --git a/phpBB/config/default/container/services_notification.yml b/phpBB/config/default/container/services_notification.yml index a10330143f..41f80cdd30 100644 --- a/phpBB/config/default/container/services_notification.yml +++ b/phpBB/config/default/container/services_notification.yml @@ -209,7 +209,7 @@ services: - '@dbal.conn' - '%core.root_path%' - '%core.php_ext%' - - '%tables.email_notifications%' + - '%tables.notification_emails%' tags: - { name: notification.method } diff --git a/phpBB/config/default/container/tables.yml b/phpBB/config/default/container/tables.yml index de082043fd..a2cf0b1a34 100644 --- a/phpBB/config/default/container/tables.yml +++ b/phpBB/config/default/container/tables.yml @@ -20,7 +20,6 @@ parameters: tables.confirm: '%core.table_prefix%confirm' tables.disallow: '%core.table_prefix%disallow' tables.drafts: '%core.table_prefix%drafts' - tables.email_notifications: '%core.table_prefix%email_notifications' tables.ext: '%core.table_prefix%ext' tables.extensions: '%core.table_prefix%extensions' tables.extension_groups: '%core.table_prefix%extension_groups' @@ -36,6 +35,7 @@ parameters: tables.migrations: '%core.table_prefix%migrations' tables.moderator_cache: '%core.table_prefix%moderator_cache' tables.modules: '%core.table_prefix%modules' + tables.notification_emails: '%core.table_prefix%notification_emails' tables.notification_types: '%core.table_prefix%notification_types' tables.notifications: '%core.table_prefix%notifications' tables.poll_options: '%core.table_prefix%poll_options' diff --git a/phpBB/phpbb/db/migration/data/v33x/add_email_notifications_table.php b/phpBB/phpbb/db/migration/data/v33x/add_notification_emails_table.php similarity index 82% rename from phpBB/phpbb/db/migration/data/v33x/add_email_notifications_table.php rename to phpBB/phpbb/db/migration/data/v33x/add_notification_emails_table.php index 0ad172f5c0..5a5f4dd354 100644 --- a/phpBB/phpbb/db/migration/data/v33x/add_email_notifications_table.php +++ b/phpBB/phpbb/db/migration/data/v33x/add_notification_emails_table.php @@ -13,7 +13,7 @@ namespace phpbb\db\migration\data\v33x; -class add_email_notifications_table extends \phpbb\db\migration\migration +class add_notification_emails_table extends \phpbb\db\migration\migration { static public function depends_on() { @@ -26,7 +26,7 @@ class add_email_notifications_table extends \phpbb\db\migration\migration { return [ 'add_tables' => [ - $this->table_prefix . 'email_notifications' => [ + $this->table_prefix . 'notification_emails' => [ 'COLUMNS' => [ 'notification_type_id' => ['USINT', 0], 'item_id' => ['ULINT', 0], @@ -42,7 +42,7 @@ class add_email_notifications_table extends \phpbb\db\migration\migration public function revert_schema() { return [ - 'drop_tables' => [$this->table_prefix . 'email_notifications'], + 'drop_tables' => [$this->table_prefix . 'notification_emails'], ]; } } diff --git a/phpBB/phpbb/notification/method/email.php b/phpBB/phpbb/notification/method/email.php index 26855603cb..61777e3c49 100644 --- a/phpBB/phpbb/notification/method/email.php +++ b/phpBB/phpbb/notification/method/email.php @@ -31,8 +31,8 @@ class email extends \phpbb\notification\method\messenger_base /** @var \phpbb\db\driver\driver_interface */ protected $db; - /** @var string */ - protected $email_notifications_table; + /** @var string Notification emails table */ + protected $notification_emails_table; /** * Notification Method email Constructor @@ -43,16 +43,16 @@ class email extends \phpbb\notification\method\messenger_base * @param \phpbb\db\driver\driver_interface $db * @param string $phpbb_root_path * @param string $php_ext - * @param string $email_notifications_table + * @param string $notification_emails_table */ - public function __construct(\phpbb\user_loader $user_loader, \phpbb\user $user, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, $phpbb_root_path, $php_ext, $email_notifications_table) + public function __construct(\phpbb\user_loader $user_loader, \phpbb\user $user, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, $phpbb_root_path, $php_ext, $notification_emails_table) { parent::__construct($user_loader, $phpbb_root_path, $php_ext); $this->user = $user; $this->config = $config; $this->db = $db; - $this->email_notifications_table = $email_notifications_table; + $this->notification_emails_table = $notification_emails_table; } /** @@ -86,7 +86,7 @@ class email extends \phpbb\notification\method\messenger_base $notified_users = array(); $sql = 'SELECT user_id - FROM ' . $this->email_notifications_table . ' + FROM ' . $this->notification_emails_table . ' WHERE notification_type_id = ' . (int) $notification_type_id . (isset($options['item_id']) ? ' AND item_id = ' . (int) $options['item_id'] : '') . (isset($options['item_parent_id']) ? ' AND item_parent_id = ' . (int) $options['item_parent_id'] : '') . @@ -106,7 +106,7 @@ class email extends \phpbb\notification\method\messenger_base */ public function notify() { - $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->email_notifications_table); + $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->notification_emails_table); /** @var \phpbb\notification\type\type_interface $notification */ foreach ($this->queue as $notification) @@ -125,7 +125,7 @@ class email extends \phpbb\notification\method\messenger_base */ public function mark_notifications($notification_type_id, $item_id, $user_id, $time = false, $mark_read = true) { - $sql = 'DELETE FROM ' . $this->email_notifications_table . ' + $sql = 'DELETE FROM ' . $this->notification_emails_table . ' WHERE ' . (($notification_type_id !== false) ? (is_array($notification_type_id) ? $this->db->sql_in_set('notification_type_id', $notification_type_id) : 'notification_type_id = ' . $notification_type_id) : '1=1') . (($user_id !== false) ? ' AND ' . (is_array($user_id) ? $this->db->sql_in_set('user_id', $user_id) : 'user_id = ' . (int) $user_id) : '') . (($item_id !== false) ? ' AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id) : ''); @@ -137,7 +137,7 @@ class email extends \phpbb\notification\method\messenger_base */ public function mark_notifications_by_parent($notification_type_id, $item_parent_id, $user_id, $time = false, $mark_read = true) { - $sql = 'DELETE FROM ' . $this->email_notifications_table . ' + $sql = 'DELETE FROM ' . $this->notification_emails_table . ' WHERE ' . (($notification_type_id !== false) ? (is_array($notification_type_id) ? $this->db->sql_in_set('notification_type_id', $notification_type_id) : 'notification_type_id = ' . $notification_type_id) : '1=1') . (($user_id !== false) ? ' AND ' . (is_array($user_id) ? $this->db->sql_in_set('user_id', $user_id) : 'user_id = ' . (int) $user_id) : '') . (($item_parent_id !== false) ? ' AND ' . (is_array($item_parent_id) ? $this->db->sql_in_set('item_parent_id', $item_parent_id, false, true) : 'item_parent_id = ' . (int) $item_parent_id) : ''); diff --git a/tests/notification/base.php b/tests/notification/base.php index 5c923133f8..1cc5893ebd 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -105,7 +105,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $phpbb_container->setParameter('tables.notifications', 'phpbb_notifications'); $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications'); $phpbb_container->setParameter('tables.notification_types', 'phpbb_notification_types'); - $phpbb_container->setParameter('tables.email_notifications', 'phpbb_email_notifications'); + $phpbb_container->setParameter('tables.notification_emails', 'phpbb_notification_emails'); $this->notifications = new phpbb_notification_manager_helper( array(), diff --git a/tests/notification/notification_method_email_test.php b/tests/notification/notification_method_email_test.php index 20ee0ef181..c92a5a0f01 100644 --- a/tests/notification/notification_method_email_test.php +++ b/tests/notification/notification_method_email_test.php @@ -87,7 +87,7 @@ class notification_method_email_test extends phpbb_tests_notification_base $phpbb_container->setParameter('tables.notifications', 'phpbb_notifications'); $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications'); $phpbb_container->setParameter('tables.notification_types', 'phpbb_notification_types'); - $phpbb_container->setParameter('tables.email_notifications', 'phpbb_email_notifications'); + $phpbb_container->setParameter('tables.notification_emails', 'phpbb_notification_emails'); $this->notification_method_email = $this->getMockBuilder('\phpbb\notification\method\email') ->setConstructorArgs([ @@ -97,7 +97,7 @@ class notification_method_email_test extends phpbb_tests_notification_base $phpbb_container->get('dbal.conn'), $phpbb_root_path, $phpEx, - $phpbb_container->getParameter('tables.email_notifications') + $phpbb_container->getParameter('tables.notification_emails') ]) ->setMethods(['notify_using_messenger']) ->getMock(); diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index edcbef76e2..82db7753b5 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -130,7 +130,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $phpbb_container->setParameter('tables.notifications', 'phpbb_notifications'); $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications'); $phpbb_container->setParameter('tables.notification_types', 'phpbb_notification_types'); - $phpbb_container->setParameter('tables.email_notifications', 'phpbb_email_notifications'); + $phpbb_container->setParameter('tables.notification_emails', 'phpbb_notification_emails'); $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); $phpbb_container->compile();