}
// Check permissions
- if ( isset( $show['patrolled'] )
- || isset( $show['!patrolled'] )
- || isset( $show['unpatrolled'] )
- || isset( $show['autopatrolled'] )
- || isset( $show['!autopatrolled'] )
- ) {
+ if ( $this->includesPatrollingFlags( $show ) ) {
if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
$this->dieWithError( 'apierror-permissiondenied-patrolflag', 'permissiondenied' );
}
/* Add fields to our query if they are specified as a needed parameter. */
$this->addFieldsIf( [ 'rc_this_oldid', 'rc_last_oldid' ], $this->fld_ids );
- if ( $this->fld_user || $this->fld_userid ) {
- $actorQuery = ActorMigration::newMigration()->getJoin( 'rc_user' );
- $this->addTables( $actorQuery['tables'] );
- $this->addFields( $actorQuery['fields'] );
- $this->addJoinConds( $actorQuery['joins'] );
- }
$this->addFieldsIf( [ 'rc_minor', 'rc_type', 'rc_bot' ], $this->fld_flags );
$this->addFieldsIf( [ 'rc_old_len', 'rc_new_len' ], $this->fld_sizes );
$this->addFieldsIf( [ 'rc_patrolled', 'rc_log_type' ], $this->fld_patrolled );
if ( !is_null( $params['tag'] ) ) {
$this->addTables( 'change_tag' );
- $this->addJoinConds( [ 'change_tag' => [ 'INNER JOIN', [ 'rc_id=ct_rc_id' ] ] ] );
+ $this->addJoinConds( [ 'change_tag' => [ 'JOIN', [ 'rc_id=ct_rc_id' ] ] ] );
$changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
try {
$this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
$this->addJoinConds( $commentQuery['joins'] );
}
+ if ( $this->fld_user || $this->fld_userid || !is_null( $this->token ) ) {
+ // Token needs rc_user for RecentChange::newFromRow/User::newFromAnyId (T228425)
+ $actorQuery = ActorMigration::newMigration()->getJoin( 'rc_user' );
+ $this->addTables( $actorQuery['tables'] );
+ $this->addFields( $actorQuery['fields'] );
+ $this->addJoinConds( $actorQuery['joins'] );
+ }
+
$this->addOption( 'LIMIT', $params['limit'] + 1 );
$hookData = [];
return $vals;
}
+ /**
+ * @param array $flagsArray flipped array (string flags are keys)
+ * @return bool
+ */
+ private function includesPatrollingFlags( array $flagsArray ) {
+ return isset( $flagsArray['patrolled'] ) ||
+ isset( $flagsArray['!patrolled'] ) ||
+ isset( $flagsArray['unpatrolled'] ) ||
+ isset( $flagsArray['autopatrolled'] ) ||
+ isset( $flagsArray['!autopatrolled'] );
+ }
+
public function getCacheMode( $params ) {
- if ( isset( $params['show'] ) ) {
- foreach ( $params['show'] as $show ) {
- if ( $show === 'patrolled' || $show === '!patrolled' ) {
- return 'private';
- }
- }
+ if ( isset( $params['show'] ) &&
+ $this->includesPatrollingFlags( array_flip( $params['show'] ) )
+ ) {
+ return 'private';
}
if ( isset( $params['token'] ) ) {
return 'private';