+ // 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->addFieldsIf( 'rev_page', $this->fld_ids );
+ $this->addFieldsIf( 'rev_id', $this->fld_ids || $this->fld_flags );
+ $this->addFieldsIf( 'page_latest', $this->fld_flags );
+ // $this->addFieldsIf( 'rev_text_id', $this->fld_ids ); // Should this field be exposed?
+ $this->addFieldsIf( 'rev_comment', $this->fld_comment || $this->fld_parsedcomment );
+ $this->addFieldsIf( 'rev_len', $this->fld_size );
+ $this->addFieldsIf( 'rev_minor_edit', $this->fld_flags );
+ $this->addFieldsIf( 'rev_parent_id', $this->fld_flags );
+ $this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled );
+
+ if ( $this->fld_tags ) {
+ $this->addTables( 'tag_summary' );
+ $this->addJoinConds( array( 'tag_summary' => array( 'LEFT JOIN', array( 'rev_id=ts_rev_id' ) ) ) );
+ $this->addFields( 'ts_tags' );
+ }