mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 01:30:15 +00:00
Merge "NotifUser: Remove $dbSource parameter from resetNotificationCount()"
This commit is contained in:
commit
ffa6922558
|
@ -412,12 +412,8 @@ class MWEchoNotifUser {
|
||||||
*
|
*
|
||||||
* NOTE: Consider calling this function from a deferred update, since it will read from and write to
|
* NOTE: Consider calling this function from a deferred update, since it will read from and write to
|
||||||
* the master DB if cross-wiki notifications are enabled.
|
* the master DB if cross-wiki notifications are enabled.
|
||||||
*
|
|
||||||
* @param int $dbSource Use master or replica database to pull count.
|
|
||||||
* Only used if $wgEchoCrossWikiNotifications is enabled.
|
|
||||||
* Do not set this to DB_REPLICA unless you know what you're doing.
|
|
||||||
*/
|
*/
|
||||||
public function resetNotificationCount( $dbSource = DB_MASTER ) {
|
public function resetNotificationCount() {
|
||||||
global $wgEchoCrossWikiNotifications;
|
global $wgEchoCrossWikiNotifications;
|
||||||
|
|
||||||
// Delete cached local counts and timestamps
|
// Delete cached local counts and timestamps
|
||||||
|
@ -437,7 +433,7 @@ class MWEchoNotifUser {
|
||||||
$uw = EchoUnreadWikis::newFromUser( $this->mUser );
|
$uw = EchoUnreadWikis::newFromUser( $this->mUser );
|
||||||
if ( $uw ) {
|
if ( $uw ) {
|
||||||
// Immediately compute new local counts and timestamps
|
// Immediately compute new local counts and timestamps
|
||||||
$newLocalData = $this->computeLocalCountsAndTimestamps( $dbSource );
|
$newLocalData = $this->computeLocalCountsAndTimestamps( DB_MASTER );
|
||||||
// Write the new values to the echo_unread_wikis table
|
// Write the new values to the echo_unread_wikis table
|
||||||
$alertTs = $newLocalData[EchoAttributeManager::ALERT]['timestamp'];
|
$alertTs = $newLocalData[EchoAttributeManager::ALERT]['timestamp'];
|
||||||
$messageTs = $newLocalData[EchoAttributeManager::MESSAGE]['timestamp'];
|
$messageTs = $newLocalData[EchoAttributeManager::MESSAGE]['timestamp'];
|
||||||
|
|
|
@ -34,9 +34,7 @@ class EchoModerationController {
|
||||||
// users whose notifications have been moderated.
|
// users whose notifications have been moderated.
|
||||||
foreach ( $affectedUserIds as $userId ) {
|
foreach ( $affectedUserIds as $userId ) {
|
||||||
$user = User::newFromId( $userId );
|
$user = User::newFromId( $userId );
|
||||||
// TODO this looks like it's still susceptible to a race condition, if the notification count
|
MWEchoNotifUser::newFromUser( $user )->resetNotificationCount();
|
||||||
// was reset from the master just before
|
|
||||||
MWEchoNotifUser::newFromUser( $user )->resetNotificationCount( DB_REPLICA );
|
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue