diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 88aa9b70dd..a2f7463dd4 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1297,7 +1297,7 @@ function get_schema_struct() $schema_data['phpbb_notifications'] = array( 'COLUMNS' => array( - 'item_type' => array('UINT', 0), + 'item_type' => array('VCHAR:25', ''), 'item_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'unread' => array('BOOL', 1), @@ -1775,7 +1775,7 @@ function get_schema_struct() $schema_data['phpbb_user_notifications'] = array( 'COLUMNS' => array( - 'item_type' => array('UINT', 0), + 'item_type' => array('VCHAR:25', ''), 'item_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'method' => array('VCHAR:25', ''), diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index ba57fe9f72..a689e1c68a 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -141,7 +141,7 @@ class phpbb_notifications_service */ // find out which users want to receive this type of notification - $notify_users = $item_type_class_name::find_users_for_notification($data); + $notify_users = $item_type_class_name::find_users_for_notification($this->phpbb_container, $data); // Make sure not to send new notifications to users who've already been notified about this item // This may happen when an item was added, but now new users are able to see the item @@ -155,6 +155,11 @@ class phpbb_notifications_service } $this->db->sql_freeresult($result); + if (!sizeof($notify_users)) + { + return; + } + // Go through each user so we can insert a row in the DB and then notify them by their desired means foreach ($notify_users as $user => $methods) { diff --git a/phpBB/includes/notifications/type/interface.php b/phpBB/includes/notifications/type/interface.php index b710a75606..ccd963ba06 100644 --- a/phpBB/includes/notifications/type/interface.php +++ b/phpBB/includes/notifications/type/interface.php @@ -31,5 +31,5 @@ interface phpbb_notifications_type_interface public function create_insert_array($type_data); - public function find_users_for_notification($type_data); + public static function find_users_for_notification(ContainerBuilder $phpbb_container, $type_data); } diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php index 7685a49614..2b2a835470 100644 --- a/phpBB/includes/notifications/type/pm.php +++ b/phpBB/includes/notifications/type/pm.php @@ -7,6 +7,8 @@ * */ +use Symfony\Component\DependencyInjection\ContainerBuilder; + /** * @ignore */ @@ -101,12 +103,13 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base * @param array $pm Data from * @return array */ - public function find_users_for_notification($pm) + public static function find_users_for_notification(ContainerBuilder $phpbb_container, $pm) { - $user = $this->phpbb_container->get('user'); + $db = $phpbb_container->get('dbal.conn'); + $user = $phpbb_container->get('user'); // Exclude guests, current user and banned users from notifications - unset($pm['recipients'][ANONYMOUS], $pm['recipients'][$user->data['user_id']]); + unset($pm['recipients'][ANONYMOUS]);//, $pm['recipients'][$user->data['user_id']]); if (!sizeof($pm['recipients'])) { @@ -115,7 +118,7 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base if (!function_exists('phpbb_get_banned_user_ids')) { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + include($phpbb_container->getParameter('core.root_path') . 'includes/functions_user.' . $phpbb_container->getParameter('core.php_ext')); } $banned_users = phpbb_get_banned_user_ids(array_keys($pm['recipients'])); $pm['recipients'] = array_diff(array_keys($pm['recipients']), $banned_users); diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php index addaa30ea6..920a53bcf2 100644 --- a/phpBB/includes/notifications/type/post.php +++ b/phpBB/includes/notifications/type/post.php @@ -7,6 +7,8 @@ * */ +use Symfony\Component\DependencyInjection\ContainerBuilder; + /** * @ignore */ diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 99e40ddee9..c3c2da4451 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1107,7 +1107,7 @@ function database_update_info() ), NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( - 'item_type' => array('UINT', 0), + 'item_type' => array('VCHAR:25', ''), 'item_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'unread' => array('BOOL', 1), @@ -1128,7 +1128,7 @@ function database_update_info() ), USER_NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( - 'item_type' => array('UINT', 0), + 'item_type' => array('VCHAR:25', ''), 'item_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'method' => array('VCHAR:25', ''), @@ -2676,10 +2676,10 @@ function change_database_data(&$no_updates, $version) // Create config value for displaying last subject on forum list if (!isset($config['display_last_subject'])) - { + { $config->set('display_last_subject', '1'); } - + $no_updates = false; if (!isset($config['assets_version']))