r104441 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104440‎ | r104441 | r104442 >
Date:15:33, 28 November 2011
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
Added "ApiGetDescription" hook
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiParamInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -319,12 +319,16 @@
320320 &$resultArr : data in this array will be added to the API result
321321
322322 'APIGetAllowedParams': use this hook to modify a module's parameters.
323 -&$module: Module object
 323+&$module: ApiBase Module object
324324 &$params: Array of parameters
325325
 326+'APIGetDescription': use this hook to modify a module's description
 327+&$module: ApiBase Module object
 328+&$desc: Array of descriptions
 329+
326330 'APIGetParamDescription': use this hook to modify a module's parameter
327331 descriptions.
328 -&$module: Module object
 332+&$module: ApiBase Module object
329333 &$desc: Array of parameter descriptions
330334
331335 'APIQueryAfterExecute': after calling the execute() method of an
Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -184,6 +184,7 @@
185185 up as a redirect to the linked page on Special:Whatlinkshere.
186186 * (bug 32609) API: Move captchaid/captchaword of action=edit from core
187187 to Captcha extension(s)
 188+* Added 'ApiGetDescription' hook.
188189
189190 === Languages updated in 1.19 ===
190191
Index: trunk/phase3/includes/api/ApiBase.php
@@ -235,7 +235,7 @@
236236 public function makeHelpMsg() {
237237 static $lnPrfx = "\n ";
238238
239 - $msg = $this->getDescription();
 239+ $msg = $this->getFinalDescription();
240240
241241 if ( $msg !== false ) {
242242
@@ -510,6 +510,7 @@
511511 /**
512512 * Get final list of parameters, after hooks have had a chance to
513513 * tweak it as needed.
 514+ *
514515 * @return array or false
515516 */
516517 public function getFinalParams() {
@@ -519,8 +520,9 @@
520521 }
521522
522523 /**
523 - * Get final description, after hooks have had a chance to tweak it as
 524+ * Get final parameter descriptions, after hooks have had a chance to tweak it as
524525 * needed.
 526+ *
525527 * @return array
526528 */
527529 public function getFinalParamDescription() {
@@ -530,6 +532,18 @@
531533 }
532534
533535 /**
 536+ * Get final module description, after hooks have had a chance to tweak it as
 537+ * needed.
 538+ *
 539+ * @return array
 540+ */
 541+ public function getFinalDescription() {
 542+ $desc = $this->getDescription();
 543+ wfRunHooks( 'ApiGetDescription', array( &$this, &$desc ) );
 544+ return $desc;
 545+ }
 546+
 547+ /**
534548 * This method mangles parameter name based on the prefix supplied to the constructor.
535549 * Override this method to change parameter name during runtime
536550 * @param $paramName string Parameter name
Index: trunk/phase3/includes/api/ApiParamInfo.php
@@ -113,7 +113,7 @@
114114 function getClassInfo( $obj ) {
115115 $result = $this->getResult();
116116 $retval['classname'] = get_class( $obj );
117 - $retval['description'] = implode( "\n", (array)$obj->getDescription() );
 117+ $retval['description'] = implode( "\n", (array)$obj->getFinalDescription() );
118118 $examples = (array)$obj->getExamples();
119119 $retval['examples'] = implode( "\n", $examples );
120120 $retval['version'] = implode( "\n", (array)$obj->getVersion() );

Sign-offs

UserFlagDate
Hasharinspected12:07, 29 November 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r104470Followup r104441...reedy19:17, 28 November 2011
r1047311.18wmf1 MFT r104441, r104470reedy20:02, 30 November 2011
r105187Fix hook name in RELEASE-NOTES-1.19 per Niklas on r104441reedy16:33, 5 December 2011

Comments

#Comment by 😂 (talk | contribs)   15:35, 28 November 2011

Wikia?

#Comment by Reedy (talk | contribs)   15:37, 28 November 2011

Nope

#Comment by 😂 (talk | contribs)   15:43, 28 November 2011

Just wrote it on a whim then? ;-)

#Comment by Reedy (talk | contribs)   15:43, 28 November 2011

Haha, nope. Wanted it to add some stuff to the API help text for ApiSandbox

#Comment by Nikerabbit (talk | contribs)   16:21, 5 December 2011

Looks like release notes still has wrong capitalization of the hook name.

Status & tagging log