From 353345d6ab816da16cdcb7de8794ed8dda0bf45e Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Wed, 17 Sep 2008 18:49:22 +0000 Subject: [PATCH] API: Adding APIAfterExecute, APIQueryAfterExecute and APIQueryGeneratorAfterExecute hooks to make extending core modules possible in a cleaner way --- RELEASE-NOTES | 2 ++ docs/hooks.txt | 13 +++++++++++++ includes/api/ApiMain.php | 1 + includes/api/ApiQuery.php | 2 ++ 4 files changed, 18 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 56ed654b15..4088d52d47 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -253,6 +253,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 15535) prop=info&inprop=protection doesn't list pre-1.10 protections if the page is also protected otherwise (1.10+ style or cascading) * list=random now has rnredirect parameter, to get random redirects. +* Added APIAfterExecute, APIQueryAfterExecute and APIQueryGeneratorAfterExecute + hooks which allow for extending core modules in a cleaner way === Languages updated in 1.14 === diff --git a/docs/hooks.txt b/docs/hooks.txt index 641b613b44..ff87eceb8c 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -269,6 +269,10 @@ before showing the edit form ( EditPage::edit() ). This is triggered on &action=edit. $EditPage : the EditPage object +'APIAfterExecute': after calling the execute() method of an API module. +Use this to extend core API modules. +&$module: Module object + 'APIEditBeforeSave': before saving a page with api.php?action=edit, after processing request parameters. Return false to let the request fail, returning an error message or an tag @@ -286,6 +290,15 @@ descriptions. &$module: Module object &$desc: Array of parameter descriptions +'APIQueryAfterExecute': after calling the execute() method of an +action=query submodule. Use this to extend core API modules. +&$module: Module object + +'APIQueryGeneratorAfterExecute': after calling the executeGenerator() +method of an action=query submodule. Use this to extend core API modules. +&$module: Module object +&$resultPageSet: ApiPageSet object + 'APIQueryInfoTokens': use this hook to add custom tokens to prop=info. Every token has an action, which will be used in the intoken parameter and in the output (actiontoken="..."), and a callback function which diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 4c41209884..b3d8a94f72 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -415,6 +415,7 @@ class ApiMain extends ApiBase { // Execute $module->profileIn(); $module->execute(); + wfRunHooks('APIAfterExecute', array(&$module)); $module->profileOut(); if (!$this->mInternalMode) { diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index 8199070e87..3bbc3196c4 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -209,6 +209,7 @@ class ApiQuery extends ApiBase { foreach ($modules as $module) { $module->profileIn(); $module->execute(); + wfRunHooks('APIQueryAfterExecute', array(&$module)); $module->profileOut(); } } @@ -381,6 +382,7 @@ class ApiQuery extends ApiBase { // populate resultPageSet with the generator output $generator->profileIn(); $generator->executeGenerator($resultPageSet); + wfRunHooks('APIQueryGeneratorAfterExecute', array(&$generator, &$resultPageSet)); $resultPageSet->finishPageSetGeneration(); $generator->profileOut(); -- 2.20.1