r94398 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94397‎ | r94398 | r94399 >
Date:23:59, 12 August 2011
Author:jeroendedauw
Status:deferred
Tags:lamecommitsummary 
Comment:
Modified paths:
  • /trunk/extensions/Maps/includes/Maps_Settings.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/includes/Maps_Settings.php
@@ -13,10 +13,21 @@
1414 */
1515 final class MapsSettings extends ExtensionSettings {
1616
 17+ /**
 18+ * Initiate the settings list if not done already.
 19+ *
 20+ * @since 1.1
 21+ *
 22+ * @return boolean True if the settings where initiates in this call.
 23+ */
1724 protected static function initIfNeeded() {
18 - parent::initIfNeeded();
 25+ $init = parent::initIfNeeded();
1926
20 - self::$settings['php-bc'] = self::getPhpCompatSettings();
 27+ if ( $init ) {
 28+ self::$settings['php-bc'] = self::getPhpCompatSettings();
 29+ }
 30+
 31+ return $init;
2132 }
2233
2334 /**
@@ -76,8 +87,23 @@
7788
7889 abstract class ExtensionSettings {
7990
 91+ /**
 92+ * The different groups of settings.
 93+ * array[ group name => array[ setting name => setting value ] ]
 94+ *
 95+ * @since 1.1
 96+ * @var array
 97+ */
8098 protected static $settings = false;
8199
 100+ /**
 101+ * Cached merged settings groups. The keys are the name of the
 102+ * cache, which is created by joining the group names with a |.
 103+ * array[ cache name => settings[] ]
 104+ *
 105+ * @since 1.1
 106+ * @var array
 107+ */
82108 protected static $mergedCaches = array();
83109
84110 /**
@@ -89,13 +115,24 @@
90116 */
91117 protected abstract static function getDefaultSettings();
92118
 119+ /**
 120+ * Initiate the settings list if not done already.
 121+ *
 122+ * @since 1.1
 123+ *
 124+ * @return boolean True if the settings where initiates in this call.
 125+ */
93126 protected static function initIfNeeded() {
94 - if ( self::$settings === false ) {
 127+ $init = self::$settings === false;
 128+
 129+ if ( $init ) {
95130 self::$settings = array(
96131 'default' => self::getDefaultSettings(),
97132 'php' => self::getPhpSettings()
98133 );
99134 }
 135+
 136+ return $init;
100137 }
101138
102139 protected static function getMergedSettings( array $groups, $cache = true ) {
@@ -213,14 +250,25 @@
214251 elseif ( $invalidateCache
215252 && ( !array_key_exists( $settingName, self::$settings[$groupName] )
216253 || self::$settings[$groupName][$settingName] !== $settingValue ) ) {
217 - foreach ( array_keys( self::$mergedCaches ) as $cacheName ) {
218 - if ( in_array( $groupName, explode( '|', $cacheName ) ) ) {
219 - unset( self::$mergedCaches[$cacheName] );
220 - }
221 - }
 254+ self::ivalidateCachesForGroup( $groupName );
222255 }
223256
224257 self::$settings[$groupName][$settingName] = $settingValue;
225258 }
226259
 260+ /**
 261+ * Invalidate the cahces that contain data from the specified group.
 262+ *
 263+ * @since 1.1
 264+ *
 265+ * @param name $group
 266+ */
 267+ protected static function ivalidateCachesForGroup( $group ) {
 268+ foreach ( array_keys( self::$mergedCaches ) as $cacheName ) {
 269+ if ( in_array( $groupName, explode( '|', $cacheName ) ) ) {
 270+ unset( self::$mergedCaches[$cacheName] );
 271+ }
 272+ }
 273+ }
 274+
227275 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r94399fu r94397, r94398jeroendedauw00:10, 13 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94397some prototypical work on new setting handling for in 1.1jeroendedauw23:46, 12 August 2011

Status & tagging log