mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
Merge "Checking that revert notification is enabled before firing it"
This commit is contained in:
commit
88f7735c72
40
Hooks.php
40
Hooks.php
|
@ -184,6 +184,7 @@ class EchoHooks {
|
||||||
* @return bool true in all cases
|
* @return bool true in all cases
|
||||||
*/
|
*/
|
||||||
public static function onArticleSaved( &$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status ) {
|
public static function onArticleSaved( &$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status ) {
|
||||||
|
global $wgEchoEnabledEvents;
|
||||||
if ( $revision ) {
|
if ( $revision ) {
|
||||||
EchoEvent::create( array(
|
EchoEvent::create( array(
|
||||||
'type' => 'edit',
|
'type' => 'edit',
|
||||||
|
@ -198,29 +199,30 @@ class EchoHooks {
|
||||||
|
|
||||||
// Handle the case of someone undoing an edit, either through the
|
// Handle the case of someone undoing an edit, either through the
|
||||||
// 'undo' link in the article history or via the API.
|
// 'undo' link in the article history or via the API.
|
||||||
global $wgRequest;
|
if ( in_array( 'reverted', $wgEchoEnabledEvents ) ) {
|
||||||
$undidRevId = $wgRequest->getVal( 'wpUndidRevision' );
|
$undidRevId = $user->getRequest()->getVal( 'wpUndidRevision' );
|
||||||
if ( $undidRevId ) {
|
if ( $undidRevId ) {
|
||||||
$undidRevision = Revision::newFromId( $undidRevId );
|
$undidRevision = Revision::newFromId( $undidRevId );
|
||||||
if ( $undidRevision ) {
|
if ( $undidRevision ) {
|
||||||
$victimId = $undidRevision->getUser();
|
$victimId = $undidRevision->getUser();
|
||||||
if ( $victimId ) { // No notifications for anonymous users
|
if ( $victimId ) { // No notifications for anonymous users
|
||||||
EchoEvent::create( array(
|
EchoEvent::create( array(
|
||||||
'type' => 'reverted',
|
'type' => 'reverted',
|
||||||
'title' => $article->getTitle(),
|
'title' => $article->getTitle(),
|
||||||
'extra' => array(
|
'extra' => array(
|
||||||
'revid' => $revision->getId(),
|
'revid' => $revision->getId(),
|
||||||
'reverted-user-id' => $victimId,
|
'reverted-user-id' => $victimId,
|
||||||
'reverted-revision-id' => $undidRevId,
|
'reverted-revision-id' => $undidRevId,
|
||||||
'method' => 'undo',
|
'method' => 'undo',
|
||||||
),
|
),
|
||||||
'agent' => $user,
|
'agent' => $user,
|
||||||
) );
|
) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue