jenkins-bot has submitted this change and it was merged.
Change subject: Implement backfillUnreadWikis.php in terms of
resetNotificationCount()
......................................................................
Implement backfillUnreadWikis.php in terms of resetNotificationCount()
This causes it to update the notification count cache as well.
Should we perhaps rename it to recacheNotificationCounts.php?
Bug: T132954
Change-Id: I540c4296f4fbadcf2267d77b53f71ee5c2eb8b52
---
M includes/NotifUser.php
M maintenance/backfillUnreadWikis.php
2 files changed, 11 insertions(+), 14 deletions(-)
Approvals:
Sbisson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/NotifUser.php b/includes/NotifUser.php
index 25b23d8..e1cb667 100644
--- a/includes/NotifUser.php
+++ b/includes/NotifUser.php
@@ -454,8 +454,9 @@
/**
* Recalculates the number of notifications that a user has.
* @param $dbSource int use master or slave database to pull count
+ * @param $deferUpdate bool Whether to defer the update to the
echo_unread_wikis table
*/
- public function resetNotificationCount( $dbSource = DB_SLAVE ) {
+ public function resetNotificationCount( $dbSource = DB_SLAVE,
$deferUpdate = true ) {
global $wgEchoCrossWikiNotifications;
// Reset alert and message counts, and store them for later
$alertCount = $this->getNotificationCount( false, $dbSource,
EchoAttributeManager::ALERT, false );
@@ -505,12 +506,17 @@
// Schedule an update to the echo_unread_wikis table
$user = $this->mUser;
- DeferredUpdates::addCallableUpdate( function () use (
$user, $alertCount, $alertUnread, $msgCount, $msgUnread ) {
+ $updateCallback = function () use ( $user, $alertCount,
$alertUnread, $msgCount, $msgUnread ) {
$uw = EchoUnreadWikis::newFromUser( $user );
if ( $uw ) {
$uw->updateCount( wfWikiID(),
$alertCount, $alertUnread, $msgCount, $msgUnread );
}
- } );
+ };
+ if ( $deferUpdate ) {
+ DeferredUpdates::addCallableUpdate(
$updateCallback );
+ } else {
+ $updateCallback();
+ }
}
$this->invalidateCache();
diff --git a/maintenance/backfillUnreadWikis.php
b/maintenance/backfillUnreadWikis.php
index b95fb5d..4e85a26 100644
--- a/maintenance/backfillUnreadWikis.php
+++ b/maintenance/backfillUnreadWikis.php
@@ -10,7 +10,7 @@
public function __construct() {
parent::__construct();
- $this->mDescription = "Backfill echo_unread_wikis table";
+ $this->mDescription = "Backfill echo_unread_wikis table and
recache notification counts for all users";
$this->setBatchSize( 300 );
}
@@ -28,16 +28,7 @@
$user = User::newFromRow( $row );
$notifUser = MWEchoNotifUser::newFromUser(
$user );
- $uw = EchoUnreadWikis::newFromUser( $user );
- if ( $uw ) {
- $alertCount =
$notifUser->getNotificationCount( false, DB_SLAVE, EchoAttributeManager::ALERT,
false );
- $alertUnread =
$notifUser->getLastUnreadNotificationTime( false, DB_SLAVE,
EchoAttributeManager::ALERT, false );
-
- $msgCount =
$notifUser->getNotificationCount( false, DB_SLAVE,
EchoAttributeManager::MESSAGE, false );
- $msgUnread =
$notifUser->getLastUnreadNotificationTime( false, DB_SLAVE,
EchoAttributeManager::MESSAGE, false );
-
- $uw->updateCount( wfWikiID(),
$alertCount, $alertUnread, $msgCount, $msgUnread );
- }
+ $notifUser->resetNotificationCount( DB_SLAVE,
false );
}
$processed += count( $batch );
--
To view, visit https://gerrit.wikimedia.org/r/293314
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I540c4296f4fbadcf2267d77b53f71ee5c2eb8b52
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits