API: Add IGNORE INDEX to avoid bad plan in ApiQueryRevisions
[lhc/web/wiklou.git] / includes / api / ApiQueryRevisions.php
index 9301f81..ee6a264 100644 (file)
@@ -114,7 +114,7 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
 
                if ( $revCount > 0 && $enumRevMode ) {
                        $this->dieWithError(
-                               [ 'apierror-revisions-nolist', $this->getModulePrefix() ], 'invalidparammix'
+                               [ 'apierror-revisions-norevids', $this->getModulePrefix() ], 'invalidparammix'
                        );
                }
 
@@ -153,9 +153,6 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
                        if ( $this->token !== null || $pageCount > 0 ) {
                                $opts[] = 'page';
                        }
-                       if ( $this->fetchContent ) {
-                               $opts[] = 'text';
-                       }
                        if ( $this->fld_user ) {
                                $opts[] = 'user';
                        }
@@ -177,7 +174,7 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
                        // Always join 'page' so orphaned revisions are filtered out
                        $this->addTables( [ 'revision', 'page' ] );
                        $this->addJoinConds(
-                               [ 'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ] ]
+                               [ 'page' => [ 'JOIN', [ 'page_id = rev_page' ] ] ]
                        );
                        $this->addFields( [
                                'rev_id' => $idField, 'rev_timestamp' => $tsField, 'rev_page' => $pageField
@@ -191,7 +188,7 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
                if ( $params['tag'] !== null ) {
                        $this->addTables( 'change_tag' );
                        $this->addJoinConds(
-                               [ 'change_tag' => [ 'INNER JOIN', [ 'rev_id=ct_rev_id' ] ] ]
+                               [ 'change_tag' => [ 'JOIN', [ 'rev_id=ct_rev_id' ] ] ]
                        );
                        $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
                        try {
@@ -268,7 +265,7 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
                                                [ 'ar_rev_id' => $revids ],
                                                __METHOD__
                                        ),
-                               ], false );
+                               ], $db::UNION_DISTINCT );
                                $res = $db->query( $sql, __METHOD__ );
                                foreach ( $res as $row ) {
                                        if ( (int)$row->id === (int)$params['startid'] ) {
@@ -392,6 +389,10 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
 
                $this->addOption( 'LIMIT', $this->limit + 1 );
 
+               // T224017: `rev_timestamp` is never the correct index to use for this module, but
+               // MariaDB (10.1.37-39) sometimes insists on trying to use it anyway. Tell it not to.
+               $this->addOption( 'IGNORE INDEX', [ 'revision' => 'rev_timestamp' ] );
+
                $count = 0;
                $generated = [];
                $hookData = [];