Alex Monk has uploaded a new change for review.
https://gerrit.wikimedia.org/r/62193
Change subject: Fire Echo event when revision is rejected
......................................................................
Fire Echo event when revision is rejected
The diff link on the notification is limited to only showing the rejection
revision compared to the previous revision by the Echo extension. This is
probably
an issue for the rollback event as well though.
Change-Id: I1b0213b229f665bdf05d52fe7859f410eecfc337
---
M FlaggedRevs.setup.php
M backend/FlaggedRevs.hooks.php
M business/RevisionReviewForm.php
3 files changed, 48 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlaggedRevs
refs/changes/93/62193/1
diff --git a/FlaggedRevs.setup.php b/FlaggedRevs.setup.php
index 145727e..2d8ec50 100644
--- a/FlaggedRevs.setup.php
+++ b/FlaggedRevs.setup.php
@@ -251,6 +251,8 @@
$wgHooks['MagicWordwgVariableIDs'][] =
'FlaggedRevsHooks::onMagicWordwgVariableIDs';
}
+ $wgHooks['EchoGetDefaultNotifiedUsers'][] =
'FlaggedRevsHooks::onEchoGetDefaultNotifiedUsers';
+
# ######## User interface #########
FlaggedRevsUISetup::defineHookHandlers( $wgHooks );
# ########
diff --git a/backend/FlaggedRevs.hooks.php b/backend/FlaggedRevs.hooks.php
index 448451b..c92158d 100644
--- a/backend/FlaggedRevs.hooks.php
+++ b/backend/FlaggedRevs.hooks.php
@@ -986,4 +986,20 @@
return true;
}
+
+ /**
+ * Handler for EchoGetDefaultNotifiedUsers hook.
+ * @param $event EchoEvent to get implicitly subscribed users for
+ * @param &$users Array to append implicitly subscribed users to.
+ * @return bool true in all cases
+ */
+ public static function onEchoGetDefaultNotifiedUsers( $event, &$users )
{
+ $extra = $event->getExtra();
+ if ( $event->getType() == 'reverted' && $extra['method'] ==
'flaggedrevs-reject' ) {
+ foreach ( $extra['reverted-users-ids'] as $userId ) {
+ $users[$userId] = User::newFromId( intval(
$userId ) );
+ }
+ }
+ return true;
+ }
}
diff --git a/business/RevisionReviewForm.php b/business/RevisionReviewForm.php
index dac749e..ef3258c 100644
--- a/business/RevisionReviewForm.php
+++ b/business/RevisionReviewForm.php
@@ -335,6 +335,36 @@
$new_text, $this->getComment(), 0, $baseRevId,
$this->user );
$status = $editStatus->isOK() ? true :
'review_cannot_undo';
+
+ if ( $status && class_exists( 'EchoEvent' ) ) {
+ $affectedRevisions = array(); // revid -> userid
+ foreach ( wfGetDB( DB_SLAVE )->select(
+ 'revision',
+ array( 'rev_id', 'rev_user' ),
+ array(
+ 'rev_id <= ' . $newRev->getId(),
+ 'rev_id > ' . $oldRev->getId(),
+ 'rev_page' => $article->getId(),
+ ),
+ __METHOD__
+ ) as $row ) {
+ $affectedRevisions[$row->rev_id] =
$row->rev_user;
+ }
+
+ EchoEvent::create( array(
+ 'type' => 'reverted',
+ 'title' => $this->page,
+ 'extra' => array(
+ 'revid' => ( new WikiPage(
$this->page ) )->getRevision()->getId(),
+ 'reverted-users-ids' =>
array_values( $affectedRevisions ),
+ 'reverted-revision-ids' =>
array_keys( $affectedRevisions ),
+ 'method' =>
'flaggedrevs-reject',
+ ),
+ 'agent' => $this->user,
+ ) );
+
+ }
+
# If this undid one edit by another logged-in user,
update user tallies
if ( $status === true
&& $newRev->getParentId() == $oldRev->getId()
--
To view, visit https://gerrit.wikimedia.org/r/62193
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1b0213b229f665bdf05d52fe7859f410eecfc337
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FlaggedRevs
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits