r44849 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44848‎ | r44849 | r44850 >
Date:18:20, 20 December 2008
Author:aaron
Status:deferred
Tags:
Comment:
Tweaks mainly from profiling
Modified paths:
  • /trunk/extensions/Configure/Configure.ext.php (modified) (history)
  • /trunk/extensions/Configure/Configure.func.php (modified) (history)
  • /trunk/extensions/Configure/Configure.obj.php (modified) (history)
  • /trunk/extensions/Configure/Configure.settings.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Configure/Configure.obj.php
@@ -79,20 +79,23 @@
8080 }
8181
8282 public function snapshotDefaults( /* options */ ) {
 83+ wfProfileIn( __METHOD__ );
8384 $options = func_get_args();
84 -
85 - if ( !is_array($this->mDefaults) || in_array( 'allow_empty', $options ) ) {
86 - if ( !is_array( $this->mDefaults ) )
 85+ $noOverride = in_array( 'no_override', $options );
 86+ if( !is_array($this->mDefaults) || in_array('allow_empty',$options) ) {
 87+ if( !is_array( $this->mDefaults ) ) {
8788 $this->mDefaults = array();
88 -
89 - $allSettings = array_keys( ConfigurationSettings::singleton( CONF_SETTINGS_BOTH )->getAllSettings() );
90 -
91 - foreach( $allSettings as $setting ) {
92 - if ( array_key_exists( $setting, $GLOBALS ) && !( in_array( 'no_override', $options ) && array_key_exists( $setting, $this->mDefaults ) ) ) {
 89+ }
 90+ $allSettings = ConfigurationSettings::singleton( CONF_SETTINGS_BOTH )->getAllSettings();
 91+ foreach( $allSettings as $setting => $type ) {
 92+ if( array_key_exists($setting,$GLOBALS) &&
 93+ !( $noOverride && array_key_exists($setting,$this->mDefaults) ) )
 94+ {
9395 $this->mDefaults[$setting] = $GLOBALS[$setting];
9496 }
9597 }
9698 }
 99+ wfProfileOut( __METHOD__ );
97100 }
98101
99102 /**
Index: trunk/extensions/Configure/Configure.settings.php
@@ -37,8 +37,7 @@
3838 * Load messages and initialise static variables
3939 */
4040 protected function loadSettingsDefs() {
41 - if ( $this->initialized )
42 - return;
 41+ if ( $this->initialized ) return;
4342 $this->initialized = true;
4443
4544 require( dirname( __FILE__ ) . '/Configure.settings-core.php' );
@@ -60,19 +59,20 @@
6160 * @return array
6261 */
6362 public function getAllExtensionsObjects() {
64 - static $list = array();
65 - if ( !empty( $list ) )
66 - return $list;
 63+ static $list;
 64+ if( isset($list) ) return $list;
 65+ wfProfileIn( __METHOD__ );
6766 $this->loadSettingsDefs();
6867 global $wgConfigureAdditionalExtensions;
6968 $extensions = array_merge( $this->extensions, $wgConfigureAdditionalExtensions );
7069 usort( $extensions, array( __CLASS__, 'compExt' ) );
71 - foreach ( $extensions as $ext ) {
 70+ foreach( $extensions as $ext ) {
7271 $ext = new WebExtension( $ext );
73 - if ( $ext->isInstalled() ) {
 72+ if( $ext->isInstalled() ) {
7473 $list[] = $ext;
7574 }
7675 }
 76+ wfProfileOut( __METHOD__ );
7777 return $list;
7878 }
7979
@@ -91,18 +91,18 @@
9292 public function getSettings() {
9393 $this->loadSettingsDefs();
9494 $ret = array();
95 - if ( ( $this->types & CONF_SETTINGS_CORE ) == CONF_SETTINGS_CORE ) {
96 - $ret += $this->settings;
 95+ if( ( $this->types & CONF_SETTINGS_CORE ) == CONF_SETTINGS_CORE ) {
 96+ $ret = $this->settings;
9797 }
98 - if ( ( $this->types & CONF_SETTINGS_EXT ) == CONF_SETTINGS_EXT ) {
 98+ if( ( $this->types & CONF_SETTINGS_EXT ) == CONF_SETTINGS_EXT ) {
9999 static $extArr;
100 - if ( !isset( $extArr ) ) {
 100+ if( !isset($extArr) ) {
101101 $extArr = array();
102 - foreach ( $this->getAllExtensionsObjects() as $ext ) {
 102+ foreach( $this->getAllExtensionsObjects() as $ext ) {
103103 $extSettings = $ext->getSettings();
104 - if ( $ext->useVariable() )
 104+ if( $ext->useVariable() )
105105 $extSettings[$ext->getVariable()] = 'bool';
106 - if ( count( $extSettings ) )
 106+ if( count( $extSettings ) )
107107 $extArr['mw-extensions'][$ext->getName()] = $extSettings;
108108 }
109109 }
@@ -117,16 +117,20 @@
118118 * @return array
119119 */
120120 public function getAllSettings() {
121 - if ( isset( $this->cache['all'] ) )
 121+ if( isset( $this->cache['all'] ) ) {
122122 return $this->cache['all'];
 123+ }
123124 $this->loadSettingsDefs();
124125 $arr = array();
125 - foreach ( $this->getSettings() as $section ) {
126 - foreach ( $section as $group ) {
127 - $arr = array_merge( $arr, $group );
 126+ foreach( $this->getSettings() as $section ) {
 127+ foreach( $section as $group ) {
 128+ foreach( $group as $var => $type ) {
 129+ $arr[$var] = $type;
 130+ }
128131 }
129132 }
130 - return $this->cache['all'] = $arr;
 133+ $this->cache['all'] = $arr;
 134+ return $this->cache['all'];
131135 }
132136
133137 /**
Index: trunk/extensions/Configure/Configure.ext.php
@@ -131,9 +131,6 @@
132132 */
133133 public function getFile() {
134134 global $wgConfigureExtDir;
135 - if ( substr( $wgConfigureExtDir, -1 ) != '/' && substr( $wgConfigureExtDir, -1 ) != '\\' ) {
136 - $wgConfigureExtDir .= '/';
137 - }
138135 return $wgConfigureExtDir . $this->mDir . '/' . $this->mFile;
139136 }
140137
@@ -223,11 +220,13 @@
224221 * @return bool
225222 */
226223 public function isInstalled() {
227 - if( $this->useVariable() )
 224+ if( $this->useVariable() ) {
228225 return true;
 226+ }
229227 global $wgConfigureOnlyUseVarForExt;
230 - if( $wgConfigureOnlyUseVarForExt )
 228+ if( $wgConfigureOnlyUseVarForExt ) {
231229 return false;
 230+ }
232231 return file_exists( $this->getFile() );
233232 }
234233 }
Index: trunk/extensions/Configure/Configure.func.php
@@ -57,7 +57,7 @@
5858 * @param $wiki String
5959 */
6060 function efConfigureSetup( $wiki = 'default' ) {
61 - global $wgConf, $wgConfigureFilesPath;
 61+ global $wgConf, $wgConfigureFilesPath, $wgConfigureExtDir;
6262 wfProfileIn( __FUNCTION__ );
6363 # Create the new configuration object...
6464 $oldConf = $wgConf;
@@ -81,6 +81,10 @@
8282 } else {
8383 efConfigureInitialise();
8484 }
 85+ # Cleanup $wgConfigureExtDir as needed
 86+ if( substr( $wgConfigureExtDir, -1 ) != '/' && substr( $wgConfigureExtDir, -1 ) != '\\' ) {
 87+ $wgConfigureExtDir .= '/';
 88+ }
8589 wfProfileOut( __FUNCTION__ );
8690 }
8791

Status & tagging log