X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=inline;f=includes%2Fpage%2FWikiPage.php;h=afe266bf71d7f6226f33a14cae83ac3f227723d3;hb=21551d2d15f2262695ad9d56d38ae0af7d942ad9;hp=ca7d74703f586df6736fa978c1a61fbf7a402864;hpb=e72c8c8aa79a2cb6d6fcd34336625661b51cd9ea;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index ca7d74703f..afe266bf71 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -26,7 +26,6 @@ use MediaWiki\MediaWikiServices; use Wikimedia\Assert\Assert; use Wikimedia\Rdbms\FakeResultWrapper; use Wikimedia\Rdbms\IDatabase; -use Wikimedia\Rdbms\DBError; use Wikimedia\Rdbms\DBUnexpectedError; /** @@ -1147,14 +1146,16 @@ class WikiPage implements Page, IDBAccessObject { return; } - Hooks::run( 'PageViewUpdates', [ $this, $user ] ); - // Update newtalk / watchlist notification status - try { - $user->clearNotification( $this->mTitle, $oldid ); - } catch ( DBError $e ) { - // Avoid outage if the master is not reachable - MWExceptionHandler::logException( $e ); - } + // Update newtalk / watchlist notification status; + // Avoid outage if the master is not reachable by using a deferred updated + DeferredUpdates::addCallableUpdate( + function () use ( $user, $oldid ) { + Hooks::run( 'PageViewUpdates', [ $this, $user ] ); + + $user->clearNotification( $this->mTitle, $oldid ); + }, + DeferredUpdates::PRESEND + ); } /** @@ -1780,7 +1781,7 @@ class WikiPage implements Page, IDBAccessObject { // Update recentchanges if ( !( $flags & EDIT_SUPPRESS_RC ) ) { // Mark as patrolled if the user can do so - $patrolled = $wgUseRCPatrol && !count( + $autopatrolled = $wgUseRCPatrol && !count( $this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) ); // Add RC row to the DB RecentChange::notifyEdit( @@ -1796,7 +1797,8 @@ class WikiPage implements Page, IDBAccessObject { $oldContent ? $oldContent->getSize() : 0, $newsize, $revisionId, - $patrolled, + $autopatrolled ? RecentChange::PRC_AUTOPATROLLED : + RecentChange::PRC_UNPATROLLED, $tags ); } @@ -2869,13 +2871,32 @@ class WikiPage implements Page, IDBAccessObject { // In the future, we may keep revisions and mark them with // the rev_deleted field, which is reserved for this purpose. + // Lock rows in `revision` and its temp tables, but not any others. + // Note array_intersect() preserves keys from the first arg, and we're + // assuming $revQuery has `revision` primary and isn't using subtables + // for anything we care about. + $res = $dbw->select( + array_intersect( + $revQuery['tables'], + [ 'revision', 'revision_comment_temp', 'revision_actor_temp' ] + ), + '1', + [ 'rev_page' => $id ], + __METHOD__, + 'FOR UPDATE', + $revQuery['joins'] + ); + foreach ( $res as $row ) { + // Fetch all rows in case the DB needs that to properly lock them. + } + // Get all of the page revisions $res = $dbw->select( $revQuery['tables'], $revQuery['fields'], [ 'rev_page' => $id ], __METHOD__, - 'FOR UPDATE', + [], $revQuery['joins'] ); @@ -3267,7 +3288,7 @@ class WikiPage implements Page, IDBAccessObject { if ( $wgUseRCPatrol ) { // Mark all reverted edits as patrolled - $set['rc_patrolled'] = 1; + $set['rc_patrolled'] = RecentChange::PRC_PATROLLED; } if ( count( $set ) ) {