X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fregistration%2FExtensionProcessor.php;h=14d822295cef3862e46a53c59d5289731457de6b;hp=39a8a3dec121ba7923f517e0e20c261240dcffbf;hb=29a5fc72e3ab7d3da28bc4cc91d4bb051b9a690a;hpb=ed92658c2f515e89a7bdfdc43c525bb1fba04a76 diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index 39a8a3dec1..14d822295c 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -378,7 +378,7 @@ class ExtensionProcessor implements Processor { protected function extractExtensionMessagesFiles( $dir, array $info ) { if ( isset( $info['ExtensionMessagesFiles'] ) ) { - $this->globals["wgExtensionMessagesFiles"] += array_map( function( $file ) use ( $dir ) { + $this->globals["wgExtensionMessagesFiles"] += array_map( function ( $file ) use ( $dir ) { return "$dir/$file"; }, $info['ExtensionMessagesFiles'] ); } @@ -450,7 +450,7 @@ class ExtensionProcessor implements Processor { } foreach ( $info['config'] as $key => $val ) { if ( $key[0] !== '@' ) { - $this->globals["$prefix$key"] = $val; + $this->addConfigGlobal( "$prefix$key", $val ); } } } @@ -478,11 +478,26 @@ class ExtensionProcessor implements Processor { 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 ) {