2015-12-15 15:41:21 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$IP = getenv( 'MW_INSTALL_PATH' );
|
|
|
|
if ( $IP === false ) {
|
|
|
|
$IP = __DIR__ . '/../../..';
|
|
|
|
}
|
|
|
|
require_once ( "$IP/maintenance/Maintenance.php" );
|
|
|
|
|
|
|
|
class BackfillUnreadWikis extends Maintenance {
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->mDescription = "Backfill echo_unread_wikis table";
|
|
|
|
|
|
|
|
$this->setBatchSize( 300 );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
global $wgEchoSharedTrackingCluster;
|
|
|
|
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
$iterator = new BatchRowIterator( $dbr, 'user', 'user_id', $this->mBatchSize );
|
|
|
|
$iterator->setFetchColumns( User::selectFields() );
|
|
|
|
|
2016-01-19 03:14:34 +00:00
|
|
|
$processed = 0;
|
2015-12-15 15:41:21 +00:00
|
|
|
foreach ( $iterator as $batch ) {
|
|
|
|
foreach ( $batch as $row ) {
|
|
|
|
$user = User::newFromRow( $row );
|
|
|
|
|
|
|
|
$notifUser = MWEchoNotifUser::newFromUser( $user );
|
|
|
|
$uw = EchoUnreadWikis::newFromUser( $user );
|
|
|
|
if ( $uw ) {
|
NotifUser: Refactor getNotificationCount() and friends, add caching for global counts
Previously, getNotificationCount() only looked at local notifications,
and foreign notifications were added in separately by getMessageCount()
and getAlertCount(). This didn't make any sense and resulted in
counter-intuitive things like I4d49b543.
Instead, add a $global flag to getNotificationCount(). If $global=false,
the local count is returned as before, but if $global=true, the
global count (=local+foreign) is returned. If $global is omitted,
the user's cross-wiki notification preference determines which is returned.
Update getLastUnreadNotificationCount() in the same way, since it had
the same issues.
Also add caching for global counts and timestamps, using a global
memc key.
Bug: T133623
Change-Id: If78bfc710acd91a075771b565cc99f4c302a104d
2016-04-27 07:12:32 +00:00
|
|
|
$alertCount = $notifUser->getNotificationCount( false, DB_SLAVE, EchoAttributeManager::ALERT, false );
|
|
|
|
$alertUnread = $notifUser->getLastUnreadNotificationTime( false, DB_SLAVE, EchoAttributeManager::ALERT, false );
|
2015-12-15 15:41:21 +00:00
|
|
|
|
NotifUser: Refactor getNotificationCount() and friends, add caching for global counts
Previously, getNotificationCount() only looked at local notifications,
and foreign notifications were added in separately by getMessageCount()
and getAlertCount(). This didn't make any sense and resulted in
counter-intuitive things like I4d49b543.
Instead, add a $global flag to getNotificationCount(). If $global=false,
the local count is returned as before, but if $global=true, the
global count (=local+foreign) is returned. If $global is omitted,
the user's cross-wiki notification preference determines which is returned.
Update getLastUnreadNotificationCount() in the same way, since it had
the same issues.
Also add caching for global counts and timestamps, using a global
memc key.
Bug: T133623
Change-Id: If78bfc710acd91a075771b565cc99f4c302a104d
2016-04-27 07:12:32 +00:00
|
|
|
$msgCount = $notifUser->getNotificationCount( false, DB_SLAVE, EchoAttributeManager::MESSAGE, false );
|
|
|
|
$msgUnread = $notifUser->getLastUnreadNotificationTime( false, DB_SLAVE, EchoAttributeManager::MESSAGE, false );
|
2015-12-15 15:41:21 +00:00
|
|
|
|
|
|
|
$uw->updateCount( wfWikiID(), $alertCount, $alertUnread, $msgCount, $msgUnread );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-19 03:14:34 +00:00
|
|
|
$processed += count( $batch );
|
|
|
|
$this->output( "Updated $processed users.\n" );
|
2015-12-15 15:41:21 +00:00
|
|
|
wfWaitForSlaves( false, false, $wgEchoSharedTrackingCluster );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$maintClass = "BackfillUnreadWikis";
|
|
|
|
require_once ( DO_MAINTENANCE );
|