r103025 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103024‎ | r103025 | r103026 >
Date:20:44, 14 November 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
separate cache settings for form data
Modified paths:
  • /trunk/extensions/SemanticForms/SemanticForms.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/SemanticForms.php
@@ -318,6 +318,18 @@
319319 # ##
320320 $sfgCacheFormDefinitions = false;
321321
 322+/**
 323+ * The cache type for storing form definitions. This cache is similar in
 324+ * function to the parser cache. Is is used to store form data which is
 325+ * expensive to regenerate, and benefits from having plenty of storage space.
 326+ *
 327+ * If this setting remains at null the setting for the $wgParserCacheType will
 328+ * be used.
 329+ *
 330+ * For available types see $wgMainCacheType.
 331+ */
 332+$sfgFormCacheType = null;
 333+
322334 # ##
323335 # When modifying red links to potentially point to a form to edit that page,
324336 # check only the properties pointing to that missing page from the page the
Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.php
@@ -849,7 +849,7 @@
850850 if ( $sfgCacheFormDefinitions && $form_id !== null ) {
851851
852852 $cachekey = wfMemcKey('ext.SemanticForms.formdefinition', $form_id);
853 - $cached_def = wfGetMainCache()->get( $cachekey );
 853+ $cached_def = self::getFormCache()->get( $cachekey );
854854
855855 // Cache hit?
856856 if ( $cached_def !== false && $cached_def !== null ) {
@@ -918,14 +918,22 @@
919919
920920 if ( $wikipage->getTitle()->getNamespace() == SF_NS_FORM ) {
921921
922 - $id = $wikipage->getId();
923 - $key = wfMemcKey('ext.SemanticForms.formdefinition', $id);
 922+ $key = wfMemcKey('ext.SemanticForms.formdefinition', $wikipage->getId() );
924923
925 - if ( wfGetMainCache()->delete($key) ) {
 924+ if ( self::getFormCache()->delete($key) ) {
926925 wfDebug( "Deleted cached formdefinition $key.\n" );
927926 }
928927 }
929928
930929 return true;
931930 }
 931+
 932+ /**
 933+ * Get the cache object used by the form cache
 934+ */
 935+ public static function getFormCache() {
 936+ global $sfgFormCacheType, $wgParserCacheType;
 937+ $ret = & wfGetCache( ( $sfgFormCacheType !== null ) ? $sfgFormCacheType : $wgParserCacheType );
 938+ return $ret;
932939 }
 940+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r113397Fix for r103025 - removed apparently-unnecessary "&" for function callyaron20:27, 8 March 2012