From: jenkins-bot Date: Tue, 24 Oct 2017 17:52:23 +0000 (+0000) Subject: Merge "registration: Only allow one extension to set a specific config setting" X-Git-Tag: 1.31.0-rc.0~1686 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=5fa4cdf860c79b32ab6ef034c6d9420c2727f695;hp=-c Merge "registration: Only allow one extension to set a specific config setting" --- 5fa4cdf860c79b32ab6ef034c6d9420c2727f695 diff --combined includes/registration/ExtensionProcessor.php index ffc7a7e08e,14d822295c..5dc0b400fb --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@@ -450,7 -450,7 +450,7 @@@ class ExtensionProcessor implements Pro } foreach ( $info['config'] as $key => $val ) { if ( $key[0] !== '@' ) { - $this->globals["$prefix$key"] = $val; + $this->addConfigGlobal( "$prefix$key", $val ); } } } @@@ -478,11 -478,26 +478,26 @@@ if ( isset( $data['path'] ) && $data['path'] ) { $value = "$dir/$value"; } - $this->globals["$prefix$key"] = $value; + $this->addConfigGlobal( "$prefix$key", $value ); } } } + /** + * Helper function to set a value to a specific global, if it isn't set already. + * + * @param string $key The config key with the prefix and anything + * @param mixed $value The value of the config + */ + private function addConfigGlobal( $key, $value ) { + if ( array_key_exists( $key, $this->globals ) ) { + throw new RuntimeException( + "The configuration setting '$key' was already set by another extension," + . " and cannot be set again." ); + } + $this->globals[$key] = $value; + } + protected function extractServiceWiringFiles( $dir, array $info ) { if ( isset( $info['ServiceWiringFiles'] ) ) { foreach ( $info['ServiceWiringFiles'] as $path ) { @@@ -520,7 -535,10 +535,7 @@@ public function getExtraAutoloaderPaths( $dir, array $info ) { $paths = []; if ( isset( $info['load_composer_autoloader'] ) && $info['load_composer_autoloader'] === true ) { - $path = "$dir/vendor/autoload.php"; - if ( file_exists( $path ) ) { - $paths[] = $path; - } + $paths[] = "$dir/vendor/autoload.php"; } return $paths; }