API: Allow extensions to specify "useless" query pages
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 10 Jul 2013 20:58:32 +0000 (16:58 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Fri, 19 Jul 2013 15:34:02 +0000 (11:34 -0400)
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
includes/DefaultSettings.php
includes/api/ApiQueryQueryPage.php

index 1766d9f..858a6f3 100644 (file)
@@ -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
index 1f5b2f7..15f6987 100644 (file)
@@ -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
  */
index c15da1a..79fe049 100644 (file)
 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];
                        }
                }