From: Lucas Werkmeister Date: Sat, 30 Mar 2019 14:16:07 +0000 (+0100) Subject: Add &$tags argument to MarkPatrolled hook X-Git-Tag: 1.34.0-rc.0~2164^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=187b1d48b3e83b93a19741c8a962a3b964950ef3;p=lhc%2Fweb%2Fwiklou.git Add &$tags argument to MarkPatrolled hook 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 --- 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' ]; }