r40965 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40964‎ | r40965 | r40966 >
Date:18:49, 17 September 2008
Author:catrope
Status:old
Tags:
Comment:
API: Adding APIAfterExecute, APIQueryAfterExecute and APIQueryGeneratorAfterExecute hooks to make extending core modules possible in a cleaner way
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuery.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -269,6 +269,10 @@
270270 on &action=edit.
271271 $EditPage : the EditPage object
272272
 273+'APIAfterExecute': after calling the execute() method of an API module.
 274+Use this to extend core API modules.
 275+&$module: Module object
 276+
273277 'APIEditBeforeSave': before saving a page with api.php?action=edit,
274278 after processing request parameters. Return false to let the request
275279 fail, returning an error message or an <edit result="Failure"> tag
@@ -286,6 +290,15 @@
287291 &$module: Module object
288292 &$desc: Array of parameter descriptions
289293
 294+'APIQueryAfterExecute': after calling the execute() method of an
 295+action=query submodule. Use this to extend core API modules.
 296+&$module: Module object
 297+
 298+'APIQueryGeneratorAfterExecute': after calling the executeGenerator()
 299+method of an action=query submodule. Use this to extend core API modules.
 300+&$module: Module object
 301+&$resultPageSet: ApiPageSet object
 302+
290303 'APIQueryInfoTokens': use this hook to add custom tokens to prop=info.
291304 Every token has an action, which will be used in the intoken parameter
292305 and in the output (actiontoken="..."), and a callback function which
Index: trunk/phase3/includes/api/ApiQuery.php
@@ -209,6 +209,7 @@
210210 foreach ($modules as $module) {
211211 $module->profileIn();
212212 $module->execute();
 213+ wfRunHooks('APIQueryAfterExecute', array(&$module));
213214 $module->profileOut();
214215 }
215216 }
@@ -381,6 +382,7 @@
382383 // populate resultPageSet with the generator output
383384 $generator->profileIn();
384385 $generator->executeGenerator($resultPageSet);
 386+ wfRunHooks('APIQueryGeneratorAfterExecute', array(&$generator, &$resultPageSet));
385387 $resultPageSet->finishPageSetGeneration();
386388 $generator->profileOut();
387389
Index: trunk/phase3/includes/api/ApiMain.php
@@ -415,6 +415,7 @@
416416 // Execute
417417 $module->profileIn();
418418 $module->execute();
 419+ wfRunHooks('APIAfterExecute', array(&$module));
419420 $module->profileOut();
420421
421422 if (!$this->mInternalMode) {
Index: trunk/phase3/RELEASE-NOTES
@@ -253,6 +253,8 @@
254254 * (bug 15535) prop=info&inprop=protection doesn't list pre-1.10 protections
255255 if the page is also protected otherwise (1.10+ style or cascading)
256256 * list=random now has rnredirect parameter, to get random redirects.
 257+* Added APIAfterExecute, APIQueryAfterExecute and APIQueryGeneratorAfterExecute
 258+ hooks which allow for extending core modules in a cleaner way
257259
258260 === Languages updated in 1.14 ===
259261