Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299391
Change subject: Created a subfunction of getMediaWikiConfig to decrease NPath complexity ...................................................................... Created a subfunction of getMediaWikiConfig to decrease NPath complexity --- M src/MediaWikiFarm.php 1 file changed, 70 insertions(+), 51 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/91/299391/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 2efd5cc..2236aaf 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -531,57 +531,9 @@ $globals['skins'] = array(); $globals['extensions'] = array(); - foreach( $this->params['config'] as $configFile ) { - - # Executable config files - if( array_key_exists( 'exec', $configFile ) ) continue; - - $theseSettings = $this->readFile( $this->paramsDir . '/' . $configFile['file'] ); - if( $theseSettings === false ) { - $this->unusable = true; - return false; - } - - # Key 'default' => no choice of the wiki - if( $configFile['key'] == 'default' ) { - - foreach( $theseSettings as $setting => $value ) { - - $wgConf->settings[$setting]['default'] = $value; - } - } - - # Key '*' => choice of any wiki - elseif( $configFile['key'] == '*' ) { - - foreach( $theseSettings as $setting => $value ) { - - foreach( $value as $suffix => $val ) { - - $wgConf->settings[$setting][$suffix] = $val; - } - } - } - - # Other key - else { - - $defaultKey = null; - if( array_key_exists( 'default', $configFile ) ) - $defaultKey = $this->replaceVariables( $configFile['default'] ); - $classicKey = $this->replaceVariables( $configFile['key'] ); - - foreach( $theseSettings as $setting => $values ) { - - foreach( $values as $wiki => $val ) { - - if( $wiki == 'default' && $defaultKey ) $wgConf->settings[$setting][$defaultKey] = $val; - else $wgConf->settings[$setting][str_replace( '*', $wiki, $classicKey )] = $val; - } - } - } - } - + # Populate wgConf + if( !$this->populatewgConf() ) + return false; // Get specific configuration for this wiki // Do not use SiteConfiguration::extractAllGlobals or the configuration caching would become @@ -719,6 +671,73 @@ return null; } + /** + * Popuplate wgConf from config files. + * + * @return bool Success. + */ + private function populatewgConf() { + + global $wgConf; + + if( $this->unusable ) + return false; + + foreach( $this->params['config'] as $configFile ) { + + # Executable config files + if( array_key_exists( 'exec', $configFile ) ) continue; + + $theseSettings = $this->readFile( $this->paramsDir . '/' . $configFile['file'] ); + if( $theseSettings === false ) { + $this->unusable = true; + return false; + } + + # Key 'default' => no choice of the wiki + if( $configFile['key'] == 'default' ) { + + foreach( $theseSettings as $setting => $value ) { + + $wgConf->settings[$setting]['default'] = $value; + } + } + + # Key '*' => choice of any wiki + elseif( $configFile['key'] == '*' ) { + + foreach( $theseSettings as $setting => $value ) { + + foreach( $value as $suffix => $val ) { + + $wgConf->settings[$setting][$suffix] = $val; + } + } + } + + # Other key + else { + + $defaultKey = null; + if( array_key_exists( 'default', $configFile ) ) + $defaultKey = $this->replaceVariables( $configFile['default'] ); + $classicKey = $this->replaceVariables( $configFile['key'] ); + + foreach( $theseSettings as $setting => $values ) { + + foreach( $values as $wiki => $val ) { + + if( $wiki == 'default' && $defaultKey ) $wgConf->settings[$setting][$defaultKey] = $val; + else $wgConf->settings[$setting][str_replace( '*', $wiki, $classicKey )] = $val; + } + } + } + } + + return true; + } + + /* -- To view, visit https://gerrit.wikimedia.org/r/299391 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9a855ff422952dc2532b5088a6c28399a8007700 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MediaWikiFarm Gerrit-Branch: master Gerrit-Owner: Seb35 <seb35wikipe...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits