r69782 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69781‎ | r69782 | r69783 >
Date:10:15, 23 July 2010
Author:catrope
Status:resolved
Tags:
Comment:
Followup to r69776: cache result of extractRequestParams() because it gets called 2 or 3 times per module per request now. Also touch up documentation here and there
Modified paths:
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuery.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryBase.php
@@ -47,8 +47,9 @@
4848 }
4949
5050 /**
51 - * Get the cache mode for the data generated by this module. Override this
52 - * in the module subclass.
 51+ * Get the cache mode for the data generated by this module. Override
 52+ * this in the module subclass. For possible return values and other
 53+ * details about cache modes, see ApiMain::setCacheMode()
5354 *
5455 * Public caching will only be allowed if *all* the modules that supply
5556 * data for a given request return a cache mode of public.
Index: trunk/phase3/includes/api/ApiQuery.php
@@ -489,6 +489,7 @@
490490
491491 /**
492492 * Create a generator object of the given type and return it
 493+ * @param $generatorName string Module name
493494 */
494495 public function newGenerator( $generatorName ) {
495496 // Find class that implements requested generator
Index: trunk/phase3/includes/api/ApiBase.php
@@ -479,16 +479,18 @@
480480 * @return array
481481 */
482482 public function extractRequestParams( $parseLimit = true ) {
483 - $params = $this->getFinalParams();
484 - $results = array();
 483+ if ( !isset( $this->mCachedRequestParams ) ) {
 484+ $params = $this->getFinalParams();
 485+ $this->mCachedRequestParams = array();
485486
486 - if ( $params ) { // getFinalParams() can return false
487 - foreach ( $params as $paramName => $paramSettings ) {
488 - $results[$paramName] = $this->getParameterFromSettings( $paramName, $paramSettings, $parseLimit );
 487+ if ( $params ) { // getFinalParams() can return false
 488+ foreach ( $params as $paramName => $paramSettings ) {
 489+ $this->mCachedRequestParams[$paramName] = $this->getParameterFromSettings( $paramName, $paramSettings, $parseLimit );
 490+ }
489491 }
490492 }
491493
492 - return $results;
 494+ return $this->mCachedRequestParams;
493495 }
494496
495497 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r69929Partial revert of r69782: reverted the cache feature, it does not correctly r...tstarling06:20, 26 July 2010
r70062Reintroduced the extractRequestParams() memoization as in r69782, but respect...tstarling04:12, 28 July 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r69776Rewrote r69339 etc. to clean up API cache header handling....tstarling07:17, 23 July 2010

Status & tagging log