API: Adding APIAfterExecute, APIQueryAfterExecute and APIQueryGeneratorAfterExecute...
authorRoan Kattouw <catrope@users.mediawiki.org>
Wed, 17 Sep 2008 18:49:22 +0000 (18:49 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Wed, 17 Sep 2008 18:49:22 +0000 (18:49 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/api/ApiMain.php
includes/api/ApiQuery.php

index 56ed654..4088d52 100644 (file)
@@ -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 ===
 
index 641b613..ff87ece 100644 (file)
@@ -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 <edit result="Failure"> 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
index 4c41209..b3d8a94 100644 (file)
@@ -415,6 +415,7 @@ class ApiMain extends ApiBase {
                // Execute
                $module->profileIn();
                $module->execute();
+               wfRunHooks('APIAfterExecute', array(&$module));
                $module->profileOut();
 
                if (!$this->mInternalMode) {
index 8199070..3bbc319 100644 (file)
@@ -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();