r56091 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r56090 | r56091 (on ViewVC) | r56092 >
Date:12:54, 9 September 2009
Author:catrope
Status:ok (Comments)
Tags:todo 
Comment:Follow-up to r55639: per CR comment, make API help caching disableable, and let the cache key depend on the version string
Modified paths:

Test cases

ParserTests

559 succeeded tests.

Diff [purge]

Index: trunk/phase3/includes/api/ApiMain.php
===================================================================
--- trunk/phase3/includes/api/ApiMain.php	(revision 56090)
+++ trunk/phase3/includes/api/ApiMain.php	(revision 56091)
@@ -555,15 +555,19 @@
 	 * Override the parent to generate help messages for all available modules.
 	 */
 	public function makeHelpMsg() {
-		global $wgMemc;
+		global $wgMemc, $wgAPICacheHelp;
 		$this->mPrinter->setHelp();
 		// Get help text from cache if present
-		$key = wfMemcKey( 'apihelp', $this->getModuleName() );
-		$cached = $wgMemc->get( $key );
-		if ( $cached )
-			return $cached;
+		$key = wfMemcKey( 'apihelp', $this->getModuleName(),
+			SpecialVersion::getVersion( 'nodb' ) );
+		if ( $wgAPICacheHelp ) {
+			$cached = $wgMemc->get( $key );
+			if ( $cached )
+				return $cached;
+		}
 		$retval = $this->reallyMakeHelpMsg();
-		$wgMemc->set( $key, $retval, 60*60 );
+		if ( $wgAPICacheHelp )
+			$wgMemc->set( $key, $retval, 60*60 );
 		return $retval;
 	}
 	
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 56090)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 56091)
@@ -3846,6 +3846,12 @@
 $wgAPIRequestLog = false;
 
 /**
+ * Cache the API help text for up to an hour. Disable this during API
+ * debugging and development
+ */
+$wgAPICacheHelp = true;
+
+/**
  * Parser test suite files to be run by parserTests.php when no specific
  * filename is passed to it.
  *

Follow-up revisions

RevisionCommit summaryAuthorDate
r56531Fix r56091: cache URLs with and without ?version separatelycatrope15:47, 17 September 2009
r56559API: Per CR comments on r56091, make the timeout for the API help cache configur...catrope19:39, 17 September 2009

Comments

#Comment by Brion VIBBER (Talk | contribs)   19:12, 10 September 2009

Would recommend making the config var the cache timeout rather than just an on/off.

Looks like the caching will still fail to update if you're enabling and disabling extensions, or doing any development that doesn't alter the reported MediaWiki version.

Status & tagging log

Views
Toolbox