X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fregistration%2FExtensionProcessor.php;h=fe617c54bb839aa9e2b1a76a713b1eb89d089bf3;hp=ce262bd23e4797fd5e3263d435fec430395dd3fc;hb=7babd362babcbf7f20adb8e12edb4f4bc1d4249f;hpb=237d3271fd313ebe09858a5c442a91216a7b61cf diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index ce262bd23e..fe617c54bb 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -378,9 +378,10 @@ class ExtensionProcessor implements Processor { protected function extractExtensionMessagesFiles( $dir, array $info ) { if ( isset( $info['ExtensionMessagesFiles'] ) ) { - $this->globals["wgExtensionMessagesFiles"] += array_map( function ( $file ) use ( $dir ) { - return "$dir/$file"; - }, $info['ExtensionMessagesFiles'] ); + foreach ( $info['ExtensionMessagesFiles'] as &$file ) { + $file = "$dir/$file"; + } + $this->globals["wgExtensionMessagesFiles"] += $info['ExtensionMessagesFiles']; } } @@ -450,7 +451,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 +479,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 ) { @@ -520,10 +536,7 @@ class ExtensionProcessor implements Processor { 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; }