mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 23:44:53 +00:00
Get undone revision id from hook param instead of request
The PageContentSaveComplete hook is now inside a deferred update, so when using the API, 'wpUndidRevision' is no longer present in the request. This gets the undone rev id from a new param added to the hook. Bug: T153567 Change-Id: Id539a7db8d8f5e902177845bd212b4d6c2500f89 Depends-On: I50dcb841cd0616acc2d69c3a685ba3cb339986c3
This commit is contained in:
parent
9934e30745
commit
56abaaf434
44
Hooks.php
44
Hooks.php
|
@ -504,10 +504,13 @@ class EchoHooks {
|
|||
* @param $flags int Edit flags
|
||||
* @param $revision Revision that was created
|
||||
* @param $status Status
|
||||
* @param $baseRevId Int
|
||||
* @param $undidRevId Int
|
||||
* @return bool true in all cases
|
||||
*/
|
||||
public static function onPageContentSaveComplete( &$article, &$user, $content, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status ) {
|
||||
global $wgEchoNotifications, $wgRequest;
|
||||
public static function onPageContentSaveComplete( &$article, &$user, $content, $summary, $minoredit,
|
||||
$watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId, $undidRevId = 0 ) {
|
||||
global $wgEchoNotifications;
|
||||
|
||||
if ( !$revision ) {
|
||||
return true;
|
||||
|
@ -568,26 +571,23 @@ class EchoHooks {
|
|||
|
||||
// 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'] ) ) {
|
||||
$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( [
|
||||
'type' => 'reverted',
|
||||
'title' => $title,
|
||||
'extra' => [
|
||||
'revid' => $revision->getId(),
|
||||
'reverted-user-id' => $victimId,
|
||||
'reverted-revision-id' => $undidRevId,
|
||||
'method' => 'undo',
|
||||
'summary' => $summary,
|
||||
],
|
||||
'agent' => $user,
|
||||
] );
|
||||
}
|
||||
if ( isset( $wgEchoNotifications['reverted'] ) && $undidRevId ) {
|
||||
$undidRevision = Revision::newFromId( $undidRevId );
|
||||
if ( $undidRevision && $undidRevision->getTitle()->equals( $title ) ) {
|
||||
$victimId = $undidRevision->getUser();
|
||||
if ( $victimId ) { // No notifications for anonymous users
|
||||
EchoEvent::create( [
|
||||
'type' => 'reverted',
|
||||
'title' => $title,
|
||||
'extra' => [
|
||||
'revid' => $revision->getId(),
|
||||
'reverted-user-id' => $victimId,
|
||||
'reverted-revision-id' => $undidRevId,
|
||||
'method' => 'undo',
|
||||
'summary' => $summary,
|
||||
],
|
||||
'agent' => $user,
|
||||
] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue