diff --git a/includes/EchoHooks.php b/includes/EchoHooks.php index c61b6b70f..7e488be06 100644 --- a/includes/EchoHooks.php +++ b/includes/EchoHooks.php @@ -1168,7 +1168,9 @@ class EchoHooks { // * User actually has new messages // * User is not viewing their user talk page, as user_newtalk // will not have been cleared yet. (bug T107655). - if ( $user->getNewtalk() && !$user->getTalkPage()->equals( $title ) ) { + $userHasNewMessages = MediaWikiServices::getInstance() + ->getTalkPageNotificationManager()->userHasNewMessages( $user ); + if ( $userHasNewMessages && !$user->getTalkPage()->equals( $title ) ) { if ( Hooks::run( 'BeforeDisplayOrangeAlert', [ $user, $title ] ) ) { $personal_urls['mytalk']['text'] = $sk->msg( 'echo-new-messages' )->text(); $personal_urls['mytalk']['class'] = [ 'mw-echo-alert' ]; diff --git a/includes/NotifUser.php b/includes/NotifUser.php index 6d514958a..79e3a10a2 100644 --- a/includes/NotifUser.php +++ b/includes/NotifUser.php @@ -254,13 +254,15 @@ class MWEchoNotifUser { // After this 'mark read', is there any unread edit-user-talk // remaining? If not, we should clear the newtalk flag. - if ( $this->mUser->getNewtalk() ) { + $talkPageNotificationManager = MediaWikiServices::getInstance() + ->getTalkPageNotificationManager(); + if ( $talkPageNotificationManager->userHasNewMessages( $this->mUser ) ) { $attributeManager = EchoAttributeManager::newFromGlobalVars(); $categoryMap = $attributeManager->getEventsByCategory(); $usertalkTypes = $categoryMap['edit-user-talk']; $unreadEditUserTalk = $this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes, null, DB_MASTER ); if ( $unreadEditUserTalk === [] ) { - $this->mUser->setNewtalk( false ); + $talkPageNotificationManager->removeUserHasNewMessages( $this->mUser ); } } } @@ -287,13 +289,15 @@ class MWEchoNotifUser { // After this 'mark unread', is there any unread edit-user-talk? // If so, we should add the edit-user-talk flag - if ( !$this->mUser->getNewtalk() ) { + $talkPageNotificationManager = MediaWikiServices::getInstance() + ->getTalkPageNotificationManager(); + if ( !$talkPageNotificationManager->userHasNewMessages( $this->mUser ) ) { $attributeManager = EchoAttributeManager::newFromGlobalVars(); $categoryMap = $attributeManager->getEventsByCategory(); $usertalkTypes = $categoryMap['edit-user-talk']; $unreadEditUserTalk = $this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes, null, DB_MASTER ); if ( $unreadEditUserTalk !== [] ) { - $this->mUser->setNewtalk( true ); + $talkPageNotificationManager->setUserHasNewMessages( $this->mUser ); } } } diff --git a/includes/model/Notification.php b/includes/model/Notification.php index da7ca3e24..5ace7154d 100644 --- a/includes/model/Notification.php +++ b/includes/model/Notification.php @@ -1,5 +1,7 @@ insert( $this ); if ( $this->event->getCategory() === 'edit-user-talk' ) { - $this->user->setNewtalk( true ); + MediaWikiServices::getInstance() + ->getTalkPageNotificationManager() + ->setUserHasNewMessages( $this->user ); } Hooks::run( 'EchoCreateNotificationComplete', [ $this ] ); }