jenkins-bot has submitted this change and it was merged. Change subject: Use DeferredUpdates::addCallableUpdate for generateEventsForRevision ......................................................................
Use DeferredUpdates::addCallableUpdate for generateEventsForRevision * This diff part of this logic is fairly slow Change-Id: Id9af5c18f852ba7f1c0d2b53257fe11cb87fc510 (cherry picked from commit 02f618d620179d26bc737ac36dfaf55bbc80fd94) --- M Hooks.php 1 file changed, 30 insertions(+), 25 deletions(-) Approvals: Ori.livneh: Looks good to me, approved jenkins-bot: Verified diff --git a/Hooks.php b/Hooks.php old mode 100644 new mode 100755 index 75864e8..a79505c --- a/Hooks.php +++ b/Hooks.php @@ -413,36 +413,41 @@ public static function onArticleSaved( &$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status ) { global $wgEchoNotifications, $wgRequest; - if ( $revision ) { - EchoDiscussionParser::generateEventsForRevision( $revision ); + if ( !$revision ) { + return true; + } - // Handle the case of someone undoing an edit, either through the - // 'undo' link in the article history or via the API. - if ( isset( $wgEchoNotifications['reverted'] ) ) { - $title = $article->getTitle(); - $undidRevId = $wgRequest->getVal( 'wpUndidRevision' ); - if ( $undidRevId ) { - $undidRevision = Revision::newFromId( $undidRevId ); - if ( $undidRevision && $undidRevision->getTitle()->equals( $title ) ) { - $victimId = $undidRevision->getUser(); - if ( $victimId ) { // No notifications for anonymous users - EchoEvent::create( array( - 'type' => 'reverted', - 'title' => $title, - 'extra' => array( - 'revid' => $revision->getId(), - 'reverted-user-id' => $victimId, - 'reverted-revision-id' => $undidRevId, - 'method' => 'undo', - ), - 'agent' => $user, - ) ); - } + // Try to do this after the HTTP response + DeferredUpdates::addCallableUpdate( function() use ( $revision ) { + EchoDiscussionParser::generateEventsForRevision( $revision ); + } ); + + // Handle the case of someone undoing an edit, either through the + // 'undo' link in the article history or via the API. + if ( isset( $wgEchoNotifications['reverted'] ) ) { + $title = $article->getTitle(); + $undidRevId = $wgRequest->getVal( 'wpUndidRevision' ); + if ( $undidRevId ) { + $undidRevision = Revision::newFromId( $undidRevId ); + if ( $undidRevision && $undidRevision->getTitle()->equals( $title ) ) { + $victimId = $undidRevision->getUser(); + if ( $victimId ) { // No notifications for anonymous users + EchoEvent::create( array( + 'type' => 'reverted', + 'title' => $title, + 'extra' => array( + 'revid' => $revision->getId(), + 'reverted-user-id' => $victimId, + 'reverted-revision-id' => $undidRevId, + 'method' => 'undo', + ), + 'agent' => $user, + ) ); } } } - } + return true; } -- To view, visit https://gerrit.wikimedia.org/r/211908 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id9af5c18f852ba7f1c0d2b53257fe11cb87fc510 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: wmf/1.26wmf5 Gerrit-Owner: Ori.livneh <o...@wikimedia.org> Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits