[ticket/14754] Rename email notifications table to fit better

PHPBB3-14754
This commit is contained in:
Marc Alexander 2020-03-15 15:08:25 +01:00
parent c61946329c
commit 9f4a240f91
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
7 changed files with 18 additions and 18 deletions

View file

@ -209,7 +209,7 @@ services:
- '@dbal.conn' - '@dbal.conn'
- '%core.root_path%' - '%core.root_path%'
- '%core.php_ext%' - '%core.php_ext%'
- '%tables.email_notifications%' - '%tables.notification_emails%'
tags: tags:
- { name: notification.method } - { name: notification.method }

View file

@ -20,7 +20,6 @@ parameters:
tables.confirm: '%core.table_prefix%confirm' tables.confirm: '%core.table_prefix%confirm'
tables.disallow: '%core.table_prefix%disallow' tables.disallow: '%core.table_prefix%disallow'
tables.drafts: '%core.table_prefix%drafts' tables.drafts: '%core.table_prefix%drafts'
tables.email_notifications: '%core.table_prefix%email_notifications'
tables.ext: '%core.table_prefix%ext' tables.ext: '%core.table_prefix%ext'
tables.extensions: '%core.table_prefix%extensions' tables.extensions: '%core.table_prefix%extensions'
tables.extension_groups: '%core.table_prefix%extension_groups' tables.extension_groups: '%core.table_prefix%extension_groups'
@ -36,6 +35,7 @@ parameters:
tables.migrations: '%core.table_prefix%migrations' tables.migrations: '%core.table_prefix%migrations'
tables.moderator_cache: '%core.table_prefix%moderator_cache' tables.moderator_cache: '%core.table_prefix%moderator_cache'
tables.modules: '%core.table_prefix%modules' tables.modules: '%core.table_prefix%modules'
tables.notification_emails: '%core.table_prefix%notification_emails'
tables.notification_types: '%core.table_prefix%notification_types' tables.notification_types: '%core.table_prefix%notification_types'
tables.notifications: '%core.table_prefix%notifications' tables.notifications: '%core.table_prefix%notifications'
tables.poll_options: '%core.table_prefix%poll_options' tables.poll_options: '%core.table_prefix%poll_options'

View file

@ -13,7 +13,7 @@
namespace phpbb\db\migration\data\v33x; 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() static public function depends_on()
{ {
@ -26,7 +26,7 @@ class add_email_notifications_table extends \phpbb\db\migration\migration
{ {
return [ return [
'add_tables' => [ 'add_tables' => [
$this->table_prefix . 'email_notifications' => [ $this->table_prefix . 'notification_emails' => [
'COLUMNS' => [ 'COLUMNS' => [
'notification_type_id' => ['USINT', 0], 'notification_type_id' => ['USINT', 0],
'item_id' => ['ULINT', 0], 'item_id' => ['ULINT', 0],
@ -42,7 +42,7 @@ class add_email_notifications_table extends \phpbb\db\migration\migration
public function revert_schema() public function revert_schema()
{ {
return [ return [
'drop_tables' => [$this->table_prefix . 'email_notifications'], 'drop_tables' => [$this->table_prefix . 'notification_emails'],
]; ];
} }
} }

View file

@ -31,8 +31,8 @@ class email extends \phpbb\notification\method\messenger_base
/** @var \phpbb\db\driver\driver_interface */ /** @var \phpbb\db\driver\driver_interface */
protected $db; protected $db;
/** @var string */ /** @var string Notification emails table */
protected $email_notifications_table; protected $notification_emails_table;
/** /**
* Notification Method email Constructor * Notification Method email Constructor
@ -43,16 +43,16 @@ class email extends \phpbb\notification\method\messenger_base
* @param \phpbb\db\driver\driver_interface $db * @param \phpbb\db\driver\driver_interface $db
* @param string $phpbb_root_path * @param string $phpbb_root_path
* @param string $php_ext * @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); parent::__construct($user_loader, $phpbb_root_path, $php_ext);
$this->user = $user; $this->user = $user;
$this->config = $config; $this->config = $config;
$this->db = $db; $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(); $notified_users = array();
$sql = 'SELECT user_id $sql = 'SELECT user_id
FROM ' . $this->email_notifications_table . ' FROM ' . $this->notification_emails_table . '
WHERE notification_type_id = ' . (int) $notification_type_id . WHERE notification_type_id = ' . (int) $notification_type_id .
(isset($options['item_id']) ? ' AND item_id = ' . (int) $options['item_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'] : '') . (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() 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 */ /** @var \phpbb\notification\type\type_interface $notification */
foreach ($this->queue as $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) 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') . 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) : '') . (($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) : ''); (($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) 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') . 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) : '') . (($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) : ''); (($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) : '');

View file

@ -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.notifications', 'phpbb_notifications');
$phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications'); $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications');
$phpbb_container->setParameter('tables.notification_types', 'phpbb_notification_types'); $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( $this->notifications = new phpbb_notification_manager_helper(
array(), array(),

View file

@ -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.notifications', 'phpbb_notifications');
$phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications'); $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications');
$phpbb_container->setParameter('tables.notification_types', 'phpbb_notification_types'); $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') $this->notification_method_email = $this->getMockBuilder('\phpbb\notification\method\email')
->setConstructorArgs([ ->setConstructorArgs([
@ -97,7 +97,7 @@ class notification_method_email_test extends phpbb_tests_notification_base
$phpbb_container->get('dbal.conn'), $phpbb_container->get('dbal.conn'),
$phpbb_root_path, $phpbb_root_path,
$phpEx, $phpEx,
$phpbb_container->getParameter('tables.email_notifications') $phpbb_container->getParameter('tables.notification_emails')
]) ])
->setMethods(['notify_using_messenger']) ->setMethods(['notify_using_messenger'])
->getMock(); ->getMock();

View file

@ -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.notifications', 'phpbb_notifications');
$phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications'); $phpbb_container->setParameter('tables.user_notifications', 'phpbb_user_notifications');
$phpbb_container->setParameter('tables.notification_types', 'phpbb_notification_types'); $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->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(); $phpbb_container->compile();