// We're after the revision table, and the corresponding page
// row for anything we retrieve. We may also need the
// recentchanges row.
- // Tables have to be in this order for STRAIGHT_JOIN
- $this->addTables(array('revision', 'page'));
+ $tables = array('page', 'revision'); // Order may change
$this->addWhere('page_id=rev_page');
// Handle continue parameter
// ... and in the specified timeframe.
// Ensure the same sort order for rev_user_text and rev_timestamp
// so our query is indexed
- $this->addWhereRange('rev_user_text', $this->params['dir'], null, null);
+ if($this->multiUserMode)
+ $this->addWhereRange('rev_user_text', $this->params['dir'], null, null);
$this->addWhereRange('rev_timestamp',
$this->params['dir'], $this->params['start'], $this->params['end'] );
$this->addWhereFld('page_namespace', $this->params['namespace']);
$this->addWhereIf('rc_patrolled != 0', isset($show['patrolled']));
}
$this->addOption('LIMIT', $this->params['limit'] + 1);
- $this->addOption('USE INDEX', array('revision' => 'usertext_timestamp'));
+ $index['revision'] = 'usertext_timestamp';
// Mandatory fields: timestamp allows request continuation
// ns+title checks if the user has access rights for this page
global $wgUser;
if(!$wgUser->useRCPatrol() && !$wgUser->useNPPatrol())
$this->dieUsage("You need the patrol right to request the patrolled flag", 'permissiondenied');
- $this->addTables('recentchanges');
// Use a redundant join condition on both
// timestamp and ID so we can use the timestamp
// index
+ $index['recentchanges'] = 'rc_user_text';
if(isset($show['patrolled']) || isset($show['!patrolled']))
{
+ // Put the tables in the right order for
+ // STRAIGHT_JOIN
+ $tables = array('revision', 'recentchanges', 'page');
$this->addOption('STRAIGHT_JOIN');
+ $this->addWhere('rc_user_text=rev_user_text');
$this->addWhere('rc_timestamp=rev_timestamp');
$this->addWhere('rc_this_oldid=rev_id');
}
else
+ {
+ $tables[] = 'recentchanges';
$this->addJoinConds(array('recentchanges' => array(
'LEFT JOIN', array(
+ 'rc_user_text=rev_user_text',
'rc_timestamp=rev_timestamp',
'rc_this_oldid=rev_id'))));
+ }
}
+ $this->addTables($tables);
+ $this->addOption('USE INDEX', $index);
$this->addFieldsIf('rev_page', $this->fld_ids);
$this->addFieldsIf('rev_id', $this->fld_ids || $this->fld_flags);
$this->addFieldsIf('page_latest', $this->fld_flags);