wikimedia / mediawiki-gadgets-RTRC

Mirror of https://gerrit.wikimedia.org/g/mediawiki/gadgets/RTRC.
https://meta.wikimedia.org/wiki/RTRC
MIT License
26 stars 11 forks source link

Not all wikis allow patrolling, but give the patrol right #91

Closed reedy closed 5 months ago

reedy commented 4 years ago

Following on from https://phabricator.wikimedia.org/T257005

The gadget at https://github.com/Krinkle/mw-gadget-rtrc/blob/master/src/rtrc.js#L566-L568 makes the assumption that from https://github.com/Krinkle/mw-gadget-rtrc/blob/master/src/rtrc.js#L1448-L1450 that if the user has the patrol right, they can get rcprop=patrolled

But it's possible for a user to have the patrol right, $wgUseRCPatrol and $wgUseNPPatrol can both be false...

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

And the user calls

    /**
     * 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' ) )
        );
    }

Which then means on officewiki we end up being served

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

because of the config

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)
Krinkle commented 5 months ago

Exported to https://phabricator.wikimedia.org/T361297.