From 94cb936e71bb58fbf8f2e62620b6ff969114bdbf Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 10 Jul 2013 16:58:32 -0400 Subject: [PATCH] API: Allow extensions to specify "useless" query pages Some query pages are not useful for ApiQueryQueryPage, as they require arguments that cannot be specified with that interface. Currently, the list of such pages is in a private static variable in ApiQueryQueryPage; this moves it to a global so extensions can add to the list. Change-Id: Ieccd2e84803dc1de4e26cba85d6cdda13916647f --- RELEASE-NOTES-1.22 | 2 ++ includes/DefaultSettings.php | 10 ++++++++++ includes/api/ApiQueryQueryPage.php | 13 ++----------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 1766d9fe80..858a6f3fcd 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -204,6 +204,8 @@ production. * Handle relative inclusions ({{../name}}) in main namespace with subpages enabled correctly (previously MediaWiki tried to include Template:Parent/name instead of just Parent/name). +* Added $wgAPIUselessQueryPages to allow extensions to flag their query pages + for non-inclusion in ApiQueryQueryPages. === API changes in 1.22 === * (bug 25553) The JSON output formatter now leaves forward slashes unescaped diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 1f5b2f7997..15f6987939 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -6034,6 +6034,16 @@ $wgAPIRequestLog = false; */ $wgAPICacheHelpTimeout = 60 * 60; +/** + * The ApiQueryQueryPages module should skip pages that are redundant to true + * API queries. + */ +$wgAPIUselessQueryPages = array( + 'MIMEsearch', // aiprop=mime + 'LinkSearch', // list=exturlusage + 'FileDuplicateSearch', // prop=duplicatefiles +); + /** * Enable AJAX framework */ diff --git a/includes/api/ApiQueryQueryPage.php b/includes/api/ApiQueryQueryPage.php index c15da1a5ba..79fe0498cf 100644 --- a/includes/api/ApiQueryQueryPage.php +++ b/includes/api/ApiQueryQueryPage.php @@ -32,15 +32,6 @@ class ApiQueryQueryPage extends ApiQueryGeneratorBase { private $qpMap; - /** - * Some query pages are useless because they're available elsewhere in the API - */ - private $uselessQueryPages = array( - 'MIMEsearch', // aiprop=mime - 'LinkSearch', // list=exturlusage - 'FileDuplicateSearch', // prop=duplicatefiles - ); - public function __construct( $query, $moduleName ) { parent::__construct( $query, $moduleName, 'qp' ); // We need to do this to make sure $wgQueryPages is set up @@ -49,10 +40,10 @@ class ApiQueryQueryPage extends ApiQueryGeneratorBase { require_once "$IP/includes/QueryPage.php"; // Build mapping from special page names to QueryPage classes - global $wgQueryPages; + global $wgQueryPages, $wgAPIUselessQueryPages; $this->qpMap = array(); foreach ( $wgQueryPages as $page ) { - if ( !in_array( $page[1], $this->uselessQueryPages ) ) { + if ( !in_array( $page[1], $wgAPIUselessQueryPages ) ) { $this->qpMap[$page[1]] = $page[0]; } } -- 2.20.1