From 187b1d48b3e83b93a19741c8a962a3b964950ef3 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Sat, 30 Mar 2019 15:16:07 +0100 Subject: [PATCH] Add &$tags argument to MarkPatrolled hook MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This will allow the OAuth extension to subscribe to this hook and add an “OAuth CID: $consumerId” tag to patrols made via OAuth. Bug: T219655 Change-Id: Ie5e6f820bbf399ec639e715afd908f78bf5c8e9a --- RELEASE-NOTES-1.33 | 2 ++ docs/hooks.txt | 1 + includes/changes/RecentChange.php | 9 ++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.33 b/RELEASE-NOTES-1.33 index 7513334819..8ed24980bc 100644 --- a/RELEASE-NOTES-1.33 +++ b/RELEASE-NOTES-1.33 @@ -110,6 +110,8 @@ For notes on 1.32.x and older releases, see HISTORY. * (T214706) LinksUpdate::getAddedExternalLinks() and LinksUpdate::getRemovedExternalLinks() were introduced. * (T213893) Added 'MaintenanceUpdateAddParams' hook +* (T219655) The MarkPatrolled hook has a new parameter for the tags + associated with this entry in the patrol log. === External library changes in 1.33 === ==== New external libraries ==== diff --git a/docs/hooks.txt b/docs/hooks.txt index e9ceb951f4..5f2c129602 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2230,6 +2230,7 @@ $rcid: ID of the revision to be marked patrolled $wcOnlySysopsCanPatrol: config setting indicating whether the user needs to be a sysop in order to mark an edit patrolled. $auto: true if the edit is being marked as patrolled automatically +&$tags: the tags to be applied to the patrol log entry 'MarkPatrolledComplete': After an edit is marked patrolled. $rcid: ID of the revision marked as patrolled diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index 2d37eacdc0..eed159d8d1 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -590,6 +590,13 @@ class RecentChange implements Taggable { public function doMarkPatrolled( User $user, $auto = false, $tags = null ) { global $wgUseRCPatrol, $wgUseNPPatrol, $wgUseFilePatrol; + // Fix up $tags so that the MarkPatrolled hook below always gets an array + if ( $tags === null ) { + $tags = []; + } elseif ( is_string( $tags ) ) { + $tags = [ $tags ]; + } + $errors = []; // If recentchanges patrol is disabled, only new pages or new file versions // can be patrolled, provided the appropriate config variable is set @@ -602,7 +609,7 @@ class RecentChange implements Taggable { $right = $auto ? 'autopatrol' : 'patrol'; $errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $user ) ); if ( !Hooks::run( 'MarkPatrolled', - [ $this->getAttribute( 'rc_id' ), &$user, false, $auto ] ) + [ $this->getAttribute( 'rc_id' ), &$user, false, $auto, &$tags ] ) ) { $errors[] = [ 'hookaborted' ]; } -- 2.20.1