From: Aaron Schulz Date: Thu, 16 Jul 2015 23:06:13 +0000 (-0700) Subject: Defer user_newtalk updates in clearNotification() to post-send X-Git-Tag: 1.31.0-rc.0~10728^2 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=64bf3a12b514bb0f88d90e268f388495e2554278;p=lhc%2Fweb%2Fwiklou.git Defer user_newtalk updates in clearNotification() to post-send * Also only issue DELETE if notifications exist. Previously, this would issue a DELETE for all self talk page views. Bug: T92007 Change-Id: Ifef11c9e5175d68d9615e59e2ed7de2f2c57bde1 --- diff --git a/includes/User.php b/includes/User.php index bd0d30b517..d627a6db3c 100644 --- a/includes/User.php +++ b/includes/User.php @@ -3385,19 +3385,24 @@ class User implements IDBAccessObject { return; } - $nextid = $oldid ? $title->getNextRevisionID( $oldid ) : null; + $that = $this; + // Try to update the DB post-send and only if needed... + DeferredUpdates::addCallableUpdate( function() use ( $that, $title, $oldid ) { + if ( !$that->getNewtalk() ) { + return; // no notifications to clear + } - if ( !$oldid || !$nextid ) { - // If we're looking at the latest revision, we should definitely clear it - $this->setNewtalk( false ); - } else { - // Otherwise we should update its revision, if it's present - if ( $this->getNewtalk() ) { - // Naturally the other one won't clear by itself - $this->setNewtalk( false ); - $this->setNewtalk( true, Revision::newFromId( $nextid ) ); + // Delete the last notifications (they stack up) + $that->setNewtalk( false ); + + // If there is a new, unseen, revision, use its timestamp + $nextid = $oldid + ? $title->getNextRevisionID( $oldid, Title::GAID_FOR_UPDATE ) + : null; + if ( $nextid ) { + $that->setNewtalk( true, Revision::newFromId( $nextid ) ); } - } + } ); } if ( !$wgUseEnotif && !$wgShowUpdatedMarker ) {