From: Aaron Schulz Date: Tue, 27 Oct 2015 04:10:54 +0000 (-0700) Subject: Completely defer EditPage::updateWatchlist X-Git-Tag: 1.31.0-rc.0~9211^2 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=bde1ab74c0077c36b9a2d4042fc5d7266b7c9c69;p=lhc%2Fweb%2Fwiklou.git Completely defer EditPage::updateWatchlist This should reduce their profile time shown on xenon Change-Id: I8e92de22755b592cc7b2d3fab36cff2761ab2bb7 --- diff --git a/includes/EditPage.php b/includes/EditPage.php index 81f35f9ea2..2bddc3ee73 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2041,7 +2041,7 @@ class EditPage { } /** - * @param Title $title + * @param User $user * @param string $oldModel * @param string $newModel * @param string $reason @@ -2059,26 +2059,26 @@ class EditPage { $log->publish( $logid ); } - /** * Register the change of watch status */ protected function updateWatchlist() { global $wgUser; - if ( $wgUser->isLoggedIn() - && $this->watchthis != $wgUser->isWatched( $this->mTitle, WatchedItem::IGNORE_USER_RIGHTS ) - ) { - $fname = __METHOD__; - $title = $this->mTitle; - $watch = $this->watchthis; - - // Do this in its own transaction to reduce contention... - $dbw = wfGetDB( DB_MASTER ); - $dbw->onTransactionIdle( function () use ( $dbw, $title, $watch, $wgUser, $fname ) { - WatchAction::doWatchOrUnwatch( $watch, $title, $wgUser ); - } ); + if ( !$wgUser->isLoggedIn() ) { + return; } + + $user = $wgUser; + $title = $this->mTitle; + $watch = $this->watchthis; + // Do this in its own transaction to reduce contention... + DeferredUpdates::addCallableUpdate( function () use ( $user, $title, $watch ) { + if ( $watch == $user->isWatched( $title, WatchedItem::IGNORE_USER_RIGHTS ) ) { + return; // nothing to change + } + WatchAction::doWatchOrUnwatch( $watch, $title, $user ); + } ); } /**