From e7be66b4d725c610e6e014b9cb4a755b0749b364 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 31 Aug 2016 13:19:13 -0400 Subject: [PATCH] ApiQueryAllDeletedRevisions: More namespace handling fixes * If the user specifically requests an empty list of namespaces, they should get no pages. * `ar_namespace` should always be in the query so MySQL can do a range search instead of a full index scan. * The example provided didn't match its description. Bug: T89665 Change-Id: I91afc25db488f75c7f2b1ef343766b4bd7da5472 --- includes/api/ApiQueryAllDeletedRevisions.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiQueryAllDeletedRevisions.php b/includes/api/ApiQueryAllDeletedRevisions.php index a559683a33..3073a951b0 100644 --- a/includes/api/ApiQueryAllDeletedRevisions.php +++ b/includes/api/ApiQueryAllDeletedRevisions.php @@ -55,6 +55,14 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase { $result = $this->getResult(); + // If the user wants no namespaces, they get no pages. + if ( $params['namespace'] === [] ) { + if ( $resultPageSet === null ) { + $result->addValue( 'query', $this->getModuleName(), [] ); + } + return; + } + // This module operates in two modes: // 'user': List deleted revs by a certain user // 'all': List all deleted revs in NS @@ -153,10 +161,10 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase { if ( $mode == 'all' ) { if ( $params['namespace'] !== null ) { $namespaces = $params['namespace']; - $this->addWhereFld( 'ar_namespace', $namespaces ); } else { $namespaces = MWNamespace::getValidNamespaces(); } + $this->addWhereFld( 'ar_namespace', $namespaces ); // For from/to/prefix, we have to consider the potential // transformations of the title in all specified namespaces. @@ -447,7 +455,7 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase { return [ 'action=query&list=alldeletedrevisions&adruser=Example&adrlimit=50' => 'apihelp-query+alldeletedrevisions-example-user', - 'action=query&list=alldeletedrevisions&adrdir=newer&adrlimit=50' + 'action=query&list=alldeletedrevisions&adrdir=newer&adrnamespace=0&adrlimit=50' => 'apihelp-query+alldeletedrevisions-example-ns-main', ]; } -- 2.20.1