- 'rc_moved_to_title'
- ));
-
- if (!is_null($prop)) {
- $prop = array_flip($prop);
-
- $this->fld_comment = isset ($prop['comment']);
- $this->fld_user = isset ($prop['user']);
- $this->fld_flags = isset ($prop['flags']);
- $this->fld_timestamp = isset ($prop['timestamp']);
- $this->fld_title = isset ($prop['title']);
- $this->fld_ids = isset ($prop['ids']);
- $this->fld_sizes = isset ($prop['sizes']);
-
- $this->addFieldsIf('rc_id', $this->fld_ids);
- $this->addFieldsIf('rc_cur_id', $this->fld_ids);
- $this->addFieldsIf('rc_this_oldid', $this->fld_ids);
- $this->addFieldsIf('rc_last_oldid', $this->fld_ids);
- $this->addFieldsIf('rc_comment', $this->fld_comment);
- $this->addFieldsIf('rc_user', $this->fld_user);
- $this->addFieldsIf('rc_user_text', $this->fld_user);
- $this->addFieldsIf('rc_minor', $this->fld_flags);
- $this->addFieldsIf('rc_bot', $this->fld_flags);
- $this->addFieldsIf('rc_new', $this->fld_flags);
- $this->addFieldsIf('rc_old_len', $this->fld_sizes);
- $this->addFieldsIf('rc_new_len', $this->fld_sizes);
- }
-
- $this->addOption('LIMIT', $limit +1);
- $this->addOption('USE INDEX', 'rc_timestamp');
-
- $data = array ();
+ 'rc_moved_to_title',
+ 'rc_deleted'
+ ) );
+
+ $showRedirects = false;
+ /* Determine what properties we need to display. */
+ if ( !is_null( $params['prop'] ) ) {
+ $prop = array_flip( $params['prop'] );
+
+ /* Set up internal members based upon params. */
+ $this->initProperties( $prop );
+
+ if ( $this->fld_patrolled && !$user->useRCPatrol() && !$user->useNPPatrol() ) {
+ $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
+ }
+
+ /* Add fields to our query if they are specified as a needed parameter. */
+ $this->addFieldsIf( array( 'rc_id', 'rc_this_oldid', 'rc_last_oldid' ), $this->fld_ids );
+ $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
+ $this->addFieldsIf( 'rc_user', $this->fld_user );
+ $this->addFieldsIf( 'rc_user_text', $this->fld_user || $this->fld_userid );
+ $this->addFieldsIf( array( 'rc_minor', 'rc_new', 'rc_bot' ) , $this->fld_flags );
+ $this->addFieldsIf( array( 'rc_old_len', 'rc_new_len' ), $this->fld_sizes );
+ $this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled );
+ $this->addFieldsIf( array( 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ), $this->fld_loginfo );
+ $showRedirects = $this->fld_redirect || isset( $show['redirect'] ) || isset( $show['!redirect'] );
+ }
+
+ if ( $this->fld_tags ) {
+ $this->addTables( 'tag_summary' );
+ $this->addJoinConds( array( 'tag_summary' => array( 'LEFT JOIN', array( 'rc_id=ts_rc_id' ) ) ) );
+ $this->addFields( 'ts_tags' );
+ }
+
+ if ( $params['toponly'] || $showRedirects ) {
+ $this->addTables( 'page' );
+ $this->addJoinConds( array( 'page' => array( 'LEFT JOIN', array( 'rc_namespace=page_namespace', 'rc_title=page_title' ) ) ) );
+ $this->addFields( 'page_is_redirect' );
+
+ if ( $params['toponly'] ) {
+ $this->addWhere( 'rc_this_oldid = page_latest' );
+ }
+ }
+
+ if ( !is_null( $params['tag'] ) ) {
+ $this->addTables( 'change_tag' );
+ $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rc_id=ct_rc_id' ) ) ) );
+ $this->addWhereFld( 'ct_tag' , $params['tag'] );
+ global $wgOldChangeTagsIndex;
+ $index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id';
+ }
+
+ $this->token = $params['token'];
+ $this->addOption( 'LIMIT', $params['limit'] + 1 );
+ $this->addOption( 'USE INDEX', $index );
+