New hooks ApiMain::moduleManager and ApiQuery::moduleManager
authorMax Semenik <maxsem.wiki@gmail.com>
Thu, 12 Feb 2015 01:38:18 +0000 (17:38 -0800)
committerMax Semenik <maxsem.wiki@gmail.com>
Mon, 23 Feb 2015 18:38:40 +0000 (10:38 -0800)
Needed to conditionally register API modules. The previous way, messing with globals
from extension functions, is getting problematic because Config class will make this
impossible.

Change-Id: I86b40aeec555dd6b3cd82cab31d96e85fdf0a665

RELEASE-NOTES-1.25
docs/hooks.txt
includes/api/ApiMain.php
includes/api/ApiQuery.php

index 5ce61e1..1621c5f 100644 (file)
@@ -107,6 +107,8 @@ production.
   to allow extensions to override how links to pages are rendered within NS_CATEGORY
 * (T19665) Special:WantedPages only lists page which having at least one red link
   pointing to it.
+* New hooks 'ApiMain::moduleManager' and 'ApiQuery::moduleManager', can be
+  used for conditional registration of API modules.
 
 ==== External libraries ====
 * MediaWiki now requires certain external libraries to be installed. In the past
@@ -278,6 +280,8 @@ production.
   * ApiQueryDeletedrevs
 * Default type param for ApiQueryWatchlist and ApiQueryRecentChanges has
   been changed from all types (e.g. including 'external') to 'edit|new|log'.
+* New hooks 'ApiMain::moduleManager' and 'ApiQuery::moduleManager', can be
+  used for conditional registration of API modules.
 
 === Languages updated in 1.25 ===
 
index e81637a..1d211af 100644 (file)
@@ -418,6 +418,10 @@ $module: ApiBase Module object
 &$help: Array of HTML strings to be joined for the output.
 $options: Array Options passed to ApiHelp::getHelp
 
+'ApiMain::moduleManager': Called when ApiMain has finished initializing its
+module manager. Can be used to conditionally register API modules.
+$moduleManager: ApiModuleManager Module manager instance
+
 'ApiOpenSearchSuggest': Called when constructing the OpenSearch results. Hooks
 can alter or append to the array.
 &$results: array with integer keys to associative arrays. Keys in associative
@@ -431,6 +435,10 @@ array:
     (url), 'width', 'height', 'alt', 'align'.
   - url: Url for the given title.
 
+'ApiQuery::moduleManager': Called when ApiQuery has finished initializing its
+module manager. Can be used to conditionally register API query modules.
+$moduleManager: ApiModuleManager Module manager instance
+
 'APIQueryAfterExecute': After calling the execute() method of an
 action=query submodule. Use this to extend core API modules.
 &$module: Module object
index 34ed523..fe01f11 100644 (file)
@@ -215,6 +215,8 @@ class ApiMain extends ApiBase {
                $this->mModuleMgr->addModules( self::$Formats, 'format' );
                $this->mModuleMgr->addModules( $config->get( 'APIFormatModules' ), 'format' );
 
+               Hooks::run( 'ApiMain::moduleManager', array( $this->mModuleMgr ) );
+
                $this->mResult = new ApiResult( $this );
                $this->mEnableWrite = $enableWrite;
 
index 514d559..9196dc7 100644 (file)
@@ -143,6 +143,8 @@ class ApiQuery extends ApiBase {
                $this->mModuleMgr->addModules( self::$QueryMetaModules, 'meta' );
                $this->mModuleMgr->addModules( $config->get( 'APIMetaModules' ), 'meta' );
 
+               Hooks::run( 'ApiQuery::moduleManager', array( $this->mModuleMgr ) );
+
                // Create PageSet that will process titles/pageids/revids/generator
                $this->mPageSet = new ApiPageSet( $this );
        }