Fix for r58399 (missing index on change_tag table), using the patch from bug 22032...
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 3 Feb 2010 23:30:19 +0000 (23:30 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 3 Feb 2010 23:30:19 +0000 (23:30 +0000)
includes/api/ApiQueryLogEvents.php
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQueryRevisions.php
includes/api/ApiQueryUserContributions.php

index 57bec76..e2c4b49 100644 (file)
@@ -69,7 +69,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        'page' => array( 'LEFT JOIN',
                                array(  'log_namespace=page_namespace',
                                        'log_title=page_title' ) ) ) );
-               $index = 'times'; // default, may change
+               $index['logging'] = 'times'; // default, may change
 
                $this->addFields( array (
                        'log_type',
@@ -97,11 +97,13 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        $this->addTables( 'change_tag' );
                        $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'log_id=ct_log_id' ) ) ) );
                        $this->addWhereFld( 'ct_tag', $params['tag'] );
+                       global $wgOldChangeTagsIndex;
+                       $index['change_tag'] = $wgOldChangeTagsIndex ?  'ct_tag' : 'change_tag_tag_id';
                }
                
                if ( !is_null( $params['type'] ) ) {
                        $this->addWhereFld( 'log_type', $params['type'] );
-                       $index = 'type_time';
+                       $index['logging'] = 'type_time';
                }
                
                $this->addWhereRange( 'log_timestamp', $params['dir'], $params['start'], $params['end'] );
@@ -115,7 +117,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        if ( !$userid )
                                $this->dieUsage( "User name $user not found", 'param_user' );
                        $this->addWhereFld( 'log_user', $userid );
-                       $index = 'user_time';
+                       $index['logging'] = 'user_time';
                }
 
                $title = $params['title'];
@@ -127,10 +129,10 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        $this->addWhereFld( 'log_title', $titleObj->getDBkey() );
 
                        // Use the title index in preference to the user index if there is a conflict
-                       $index = is_null( $user ) ? 'page_time' : array( 'page_time', 'user_time' );
+                       $index['logging'] = is_null( $user ) ? 'page_time' : array( 'page_time', 'user_time' );
                }
 
-               $this->addOption( 'USE INDEX', array( 'logging' => $index ) );
+               $this->addOption( 'USE INDEX', $index );
 
                // Paranoia: avoid brute force searches (bug 17342)
                if ( !is_null( $title ) ) {
index 2c67982..0eb7dbd 100644 (file)
@@ -114,7 +114,7 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                 */
                $db = $this->getDB();
                $this->addTables( 'recentchanges' );
-               $index = 'rc_timestamp'; // May change
+               $index['recentchanges'] = 'rc_timestamp'; // May change
                $this->addWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
                $this->addWhereFld( 'rc_namespace', $params['namespace'] );
                $this->addWhereFld( 'rc_deleted', 0 );
@@ -161,7 +161,7 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                if ( !is_null( $params['user'] ) )
                {
                        $this->addWhereFld( 'rc_user_text', $params['user'] );
-                       $index = 'rc_user_text';
+                       $index['recentchanges'] = 'rc_user_text';
                }
                
                if ( !is_null( $params['excludeuser'] ) )
@@ -227,10 +227,13 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                        $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', array( 'recentchanges' => $index ) );
+               $this->addOption( 'USE INDEX', $index );
 
                $count = 0;
                /* Perform the actual query. */
index 9a98e7d..4a2af3a 100644 (file)
@@ -157,6 +157,8 @@ class ApiQueryRevisions extends ApiQueryBase {
                        $this->addTables( 'change_tag' );
                        $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rev_id=ct_rev_id' ) ) ) );
                        $this->addWhereFld( 'ct_tag' , $params['tag'] );
+                       global $wgOldChangeTagsIndex;
+                       $index['change_tag'] = $wgOldChangeTagsIndex ?  'ct_tag' : 'change_tag_tag_id';
                }
                
                if ( isset( $prop['content'] ) || !is_null( $this->difftotext ) ) {
@@ -295,6 +297,7 @@ class ApiQueryRevisions extends ApiQueryBase {
                        ApiBase :: dieDebug( __METHOD__, 'param validation?' );
 
                $this->addOption( 'LIMIT', $limit + 1 );
+               $this->addOption( 'USE INDEX', $index );
 
                $data = array ();
                $count = 0;
index ad73518..4a52f28 100644 (file)
@@ -238,7 +238,6 @@ class ApiQueryContributions extends ApiQueryBase {
                }
 
                $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 );
@@ -260,7 +259,11 @@ class ApiQueryContributions extends ApiQueryBase {
                        $this->addTables( 'change_tag' );
                        $this->addJoinConds( array( 'change_tag' => array( 'INNER JOIN', array( 'rev_id=ct_rev_id' ) ) ) );
                        $this->addWhereFld( 'ct_tag', $this->params['tag'] );
+                       global $wgOldChangeTagsIndex;
+                       $index['change_tag'] = $wgOldChangeTagsIndex ?  'ct_tag' : 'change_tag_tag_id';
                }
+               
+               $this->addOption( 'USE INDEX', $index );
        }
 
        /**
@@ -390,6 +393,7 @@ class ApiQueryContributions extends ApiQueryBase {
                                        '!patrolled',
                                )
                        ),
+                       'tag' => null,
                );
        }
 
@@ -406,6 +410,7 @@ class ApiQueryContributions extends ApiQueryBase {
                        'prop' => 'Include additional pieces of information',
                        'show' => array( 'Show only items that meet this criteria, e.g. non minor edits only: show=!minor',
                                        'NOTE: if show=patrolled or show=!patrolled is set, revisions older than $wgRCMaxAge won\'t be shown', ),
+                       'tag' => 'Only list revisions tagged with this tag',
                );
        }