diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 4eaedc4041..11a672a2ed 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -894,11 +894,11 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s /* @var $phpbb_notifications \phpbb\notification\manager */ $phpbb_notifications = $phpbb_container->get('notification_manager'); - $phpbb_notifications->delete_notifications(array( + $phpbb_notifications->delete_notifications_by_types([ 'notification.type.topic', 'notification.type.approve_topic', 'notification.type.topic_in_queue', - ), $topic_ids); + ], $topic_ids); return $return; } @@ -1185,7 +1185,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = /* @var $phpbb_notifications \phpbb\notification\manager */ $phpbb_notifications = $phpbb_container->get('notification_manager'); - $phpbb_notifications->delete_notifications($delete_notifications_types, $post_ids); + $phpbb_notifications->delete_notifications_by_types($delete_notifications_types, $post_ids); return count($post_ids); } diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index e25c0f2952..9c4fe8203a 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -474,25 +474,17 @@ class manager } /** - * Delete a notification - * - * @param string|array $notification_type_name Type identifier or array of item types (only acceptable if the $item_id is identical for the specified types) - * @param int|array $item_id Identifier within the type (or array of ids) - * @param mixed $parent_id Parent identifier within the type (or array of ids), used in combination with item_id if specified (Default: false; not checked) - * @param mixed $user_id User id (Default: false; not checked) + * Delete notifications of specified type + * + * @param string $notification_type_name Type identifier + * @param int|array $item_id Identifier within the type (or array of ids) + * @param mixed $parent_id Parent identifier within the type (or array of ids), used in combination with item_id if specified (Default: false; not checked) + * @param mixed $user_id User id (Default: false; not checked) + * + * @return void */ - public function delete_notifications($notification_type_name, $item_id, $parent_id = false, $user_id = false) + public function delete_notifications(string $notification_type_name, $item_id, $parent_id = false, $user_id = false): void { - if (is_array($notification_type_name)) - { - foreach ($notification_type_name as $type) - { - $this->delete_notifications($type, $item_id, $parent_id, $user_id); - } - - return; - } - $notification_type_id = $this->get_notification_type_id($notification_type_name); /** @var method\method_interface $method */ @@ -502,6 +494,24 @@ class manager } } + /** + * Delete notifications specified by multiple types + * + * @param array $notification_type_names Array of item types (only acceptable if the $item_id is identical for the specified types) + * @param int|array $item_id Identifier within the type (or array of ids) + * @param mixed $parent_id Parent identifier within the type (or array of ids), used in combination with item_id if specified (Default: false; not checked) + * @param mixed $user_id User id (Default: false; not checked) + * + * @return void + */ + public function delete_notifications_by_types(array $notification_type_names, $item_id, $parent_id = false, $user_id = false): void + { + foreach ($notification_type_names as $type) + { + $this->delete_notifications($type, $item_id, $parent_id, $user_id); + } + } + /** * Get all of the subscription types * diff --git a/tests/mock/notification_manager.php b/tests/mock/notification_manager.php index 952c0db489..0b70d264eb 100644 --- a/tests/mock/notification_manager.php +++ b/tests/mock/notification_manager.php @@ -61,6 +61,10 @@ class phpbb_mock_notification_manager { } + public function delete_notifications_by_types() + { + } + public function get_subscription_types() { return array();