Revert my fix for summary pings in reverts

To redo more properly.

This reverts commit 74eacad8d6.

Bug: T190374
Change-Id: If178ed1a497df5276894f86d7a3312811651ce6b
This commit is contained in:
Max Semenik 2018-03-26 11:54:03 -07:00
parent 716598242c
commit 6229cadd2e
3 changed files with 38 additions and 36 deletions

View file

@ -598,15 +598,14 @@ class EchoHooks {
if ( $undidRevision && $undidRevision->getTitle()->equals( $title ) ) {
$victimId = $undidRevision->getUser();
if ( $victimId ) { // No notifications for anonymous users
$revisionCount = self::countRevisions( $wikiPage->getId(), $baseRevId, $undidRevId );
EchoEvent::create( [
'type' => 'reverted',
'title' => $title,
'extra' => [
'revid' => $revision->getId(),
'reverted-user-id' => $victimId,
'reverted-revision-count' => $revisionCount,
'reverted-revision-id' => $undidRevId,
'method' => 'undo',
'summary' => $summary,
],
'agent' => $user,
@ -618,32 +617,6 @@ class EchoHooks {
return true;
}
/**
* Counts revisions int a page between two given revisions
*
* @param int $pageId
* @param int $revIdFrom
* @param int $revIdTo
* @return bool|int
*/
private static function countRevisions( $pageId, $revIdFrom, $revIdTo ) {
// The edit has just been made, can't guarantee it's on replicas
$dbw = wfGetDB( DB_MASTER );
$count = $dbw->selectField( 'revision',
'COUNT(*)',
[
'rev_page' => $pageId,
"rev_id > {$dbw->addQuotes( $revIdFrom )}",
"rev_id <= {$dbw->addQuotes( $revIdTo )}",
],
__METHOD__
);
if ( $count !== false ) {
$count = (int)$count;
}
return $count;
}
/**
* Handler for EchoAbortEmailNotification hook
* @param User $user
@ -1213,6 +1186,40 @@ class EchoHooks {
}
}
/**
* Handler for ArticleRollbackComplete hook.
* @see http://www.mediawiki.org/wiki/Manual:Hooks/ArticleRollbackComplete
*
* @param WikiPage $wikiPage The article that was edited
* @param User $agent The user who did the rollback
* @param Revision $newRevision The revision the page was reverted back to
* @param Revision $oldRevision The revision of the top edit that was reverted
*
* @return bool true in all cases
*/
public static function onRollbackComplete( WikiPage $wikiPage, $agent, $newRevision, $oldRevision ) {
$victimId = $oldRevision->getUser();
if (
$victimId && // No notifications for anonymous users
!$oldRevision->getContent()->equals( $newRevision->getContent() ) // No notifications for null rollbacks
) {
EchoEvent::create( [
'type' => 'reverted',
'title' => $wikiPage->getTitle(),
'extra' => [
'revid' => $wikiPage->getRevision()->getId(),
'reverted-user-id' => $victimId,
'reverted-revision-id' => $oldRevision->getId(),
'method' => 'rollback',
],
'agent' => $agent,
] );
}
return true;
}
/**
* Handler for UserSaveSettings hook.
* @see http://www.mediawiki.org/wiki/Manual:Hooks/UserSaveSettings

View file

@ -435,6 +435,7 @@
"EchoAbortEmailNotification": "EchoHooks::onEchoAbortEmailNotification",
"PageContentSaveComplete": "EchoHooks::onPageContentSaveComplete",
"LocalUserCreated": "EchoHooks::onLocalUserCreated",
"ArticleRollbackComplete": "EchoHooks::onRollbackComplete",
"UserSaveSettings": "EchoHooks::onUserSaveSettings",
"AbortTalkPageEmailNotification": "EchoHooks::onAbortTalkPageEmailNotification",
"SendWatchlistEmailNotification": "EchoHooks::onSendWatchlistEmailNotification",

View file

@ -62,18 +62,12 @@ class EchoRevertedPresentationModel extends EchoEventPresentationModel {
* @return int
*/
private function getNumberOfEdits() {
// b/c for old notifications
$method = $this->event->getExtraParam( 'method' );
if ( $method && $method === 'rollback' ) {
return 2;
} else {
return 1;
}
$count = $this->event->getExtraParam( 'reverted-revision-count' );
if ( $count > 0 ) {
return $count;
}
// "Educated guess"
return 1;
}
private function isAutomaticSummary( $summary ) {