From: daniel Date: Wed, 24 Oct 2012 13:19:44 +0000 (+0200) Subject: (Bug 41298) partial fix: re-apply I9441a277 X-Git-Tag: 1.31.0-rc.0~21888 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=0fcd7a677870380c340dc8b1f00ee901763d5339;p=lhc%2Fweb%2Fwiklou.git (Bug 41298) partial fix: re-apply I9441a277 Apparently, this change got lost during merge. Oops. Change-Id: I75ddf1d9f2abfa97fb76d47da6fadd63658c0d46 --- diff --git a/includes/EditPage.php b/includes/EditPage.php index d7b658fbd6..e4759fa977 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1603,7 +1603,7 @@ class EditPage { if ( $doEditStatus->isOK() ) { $result['redirect'] = $content->isRedirect(); - $this->commitWatch(); + $this->updateWatchlist(); wfProfileOut( __METHOD__ ); return $status; } else { @@ -1624,19 +1624,27 @@ class EditPage { } /** - * Commit the change of watch status + * Register the change of watch status */ - protected function commitWatch() { + protected function updateWatchlist() { global $wgUser; + if ( $wgUser->isLoggedIn() && $this->watchthis != $wgUser->isWatched( $this->mTitle ) ) { + $fname = __METHOD__; + $title = $this->mTitle; + $watch = $this->watchthis; + + // Do this in its own transaction to reduce contention... $dbw = wfGetDB( DB_MASTER ); - $dbw->begin( __METHOD__ ); - if ( $this->watchthis ) { - WatchAction::doWatch( $this->mTitle, $wgUser ); - } else { - WatchAction::doUnwatch( $this->mTitle, $wgUser ); - } - $dbw->commit( __METHOD__ ); + $dbw->onTransactionIdle( function() use ( $dbw, $title, $watch, $wgUser, $fname ) { + $dbw->begin( $fname ); + if ( $watch ) { + WatchAction::doWatch( $title, $wgUser ); + } else { + WatchAction::doUnwatch( $title, $wgUser ); + } + $dbw->commit( $fname ); + } ); } }