Page MenuHomePhabricator

apierror-permissiondenied-patrolflag is misleading
Open, LowPublic

Description

Using https://meta.wikimedia.org/wiki/User:Krinkle/Tools/Real-Time_Recent_Changes it does an API query of

https://office.wikimedia.org/w/api.php?rcdir=older&rclimit=25&rcshow=!bot&rcprop=flags%7Ctimestamp%7Cuser%7Ctitle%7Cparsedcomment%7Csizes%7Cids%7Cpatrolled&rctype=edit%7Cnew&format=json&action=query&list=recentchanges

Which gives an error of

	"apierror-permissiondenied-patrolflag": "You need the <code>patrol</code> or <code>patrolmarks</code> right to request the patrolled flag.",

But as a sysop on officewiki, I have patrol (but not patrolmarks)

If we look at ApiQueryRecentChanges.php

			// Check permissions
			if ( $this->includesPatrollingFlags( $show ) ) {
				if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
					$this->dieWithError( 'apierror-permissiondenied-patrolflag', 'permissiondenied' );
				}
			}

And then look at those user functions

	/**
	 * Check whether to enable recent changes patrol features for this user
	 * @return bool True or false
	 */
	public function useRCPatrol() {
		global $wgUseRCPatrol;
		return $wgUseRCPatrol && $this->isAllowedAny( 'patrol', 'patrolmarks' );
	}

	/**
	 * Check whether to enable new pages patrol features for this user
	 * @return bool True or false
	 */
	public function useNPPatrol() {
		global $wgUseRCPatrol, $wgUseNPPatrol;
		return (
			( $wgUseRCPatrol || $wgUseNPPatrol )
				&& ( $this->isAllowedAny( 'patrol', 'patrolmarks' ) )
		);
	}

If we compare officewiki to enwiki:

reedy@deploy1001:~$ mwscript eval.php officewiki
> var_dump( $wgUseRCPatrol, $wgUseNPPatrol );
bool(false)
bool(false)

reedy@deploy1001:~$ mwscript eval.php enwiki
> var_dump( $wgUseRCPatrol, $wgUseNPPatrol );
bool(false)
bool(true)

So, as both $wgUseRCPatrol and $wgUseNPPatrol are false, this can't be done, and leads to this misleading error message saying I'm missing a right, when in fact it's actually because of two config variables both being false

Event Timeline

Reedy created this task.Jul 2 2020, 9:39 PM
Restricted Application added a project: Platform Engineering. · View Herald TranscriptJul 2 2020, 9:39 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Reedy updated the task description. (Show Details)Jul 2 2020, 9:44 PM
Reedy added a comment.Jul 2 2020, 9:52 PM

Issue filed for RTRC gadget too at https://github.com/Krinkle/mw-gadget-rtrc/issues/91 because that makes an assumption

eprodromou triaged this task as Low priority.Jul 7 2020, 8:16 PM
eprodromou added a subscriber: eprodromou.

OK, looks like there's some logic to revise here, too.