From e2bf80da8f13fae25de5e9ac78dc461a9557aaef Mon Sep 17 00:00:00 2001 From: Kaldari Date: Thu, 1 Nov 2012 13:15:37 -0700 Subject: [PATCH] Checking that revert notification is enabled before firing it Change-Id: I9775b8ef1ec137f5622ee07758f50d58c50e12c9 --- Hooks.php | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/Hooks.php b/Hooks.php index 82fceef53..ab6242891 100644 --- a/Hooks.php +++ b/Hooks.php @@ -184,6 +184,7 @@ class EchoHooks { * @return bool true in all cases */ public static function onArticleSaved( &$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status ) { + global $wgEchoEnabledEvents; if ( $revision ) { EchoEvent::create( array( 'type' => 'edit', @@ -198,29 +199,30 @@ class EchoHooks { // Handle the case of someone undoing an edit, either through the // 'undo' link in the article history or via the API. - global $wgRequest; - $undidRevId = $wgRequest->getVal( 'wpUndidRevision' ); - if ( $undidRevId ) { - $undidRevision = Revision::newFromId( $undidRevId ); - if ( $undidRevision ) { - $victimId = $undidRevision->getUser(); - if ( $victimId ) { // No notifications for anonymous users - EchoEvent::create( array( - 'type' => 'reverted', - 'title' => $article->getTitle(), - 'extra' => array( - 'revid' => $revision->getId(), - 'reverted-user-id' => $victimId, - 'reverted-revision-id' => $undidRevId, - 'method' => 'undo', - ), - 'agent' => $user, - ) ); + if ( in_array( 'reverted', $wgEchoEnabledEvents ) ) { + $undidRevId = $user->getRequest()->getVal( 'wpUndidRevision' ); + if ( $undidRevId ) { + $undidRevision = Revision::newFromId( $undidRevId ); + if ( $undidRevision ) { + $victimId = $undidRevision->getUser(); + if ( $victimId ) { // No notifications for anonymous users + EchoEvent::create( array( + 'type' => 'reverted', + 'title' => $article->getTitle(), + 'extra' => array( + 'revid' => $revision->getId(), + 'reverted-user-id' => $victimId, + 'reverted-revision-id' => $undidRevId, + 'method' => 'undo', + ), + 'agent' => $user, + ) ); + } } } } - } + } return true; }