Make WikiPage::doViewUpdates use a PRESEND deferred update
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 26 Mar 2018 04:04:11 +0000 (21:04 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Mon, 26 Mar 2018 19:32:07 +0000 (19:32 +0000)
This is better than a dubious try/catch which had the off chance
of letting partial implicit transactions be committed.

Change-Id: Ied4870df166dc5a8224866284ea6e1958e65f499

includes/page/WikiPage.php

index 32953df..a7305fb 100644 (file)
@@ -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
+               );
        }
 
        /**