*/
public function extractInfo( $path, array $info, $version ) {
$dir = dirname( $path );
- if ( $version === 2 ) {
- $this->extractConfig2( $info, $dir );
- } else {
- // $version === 1
- $this->extractConfig1( $info );
- }
$this->extractHooks( $info );
$this->extractExtensionMessagesFiles( $dir, $info );
$this->extractMessagesDirs( $dir, $info );
$this->callbacks[$name] = $info['callback'];
}
+ // config should be after all core globals are extracted,
+ // so duplicate setting detection will work fully
+ if ( $version === 2 ) {
+ $this->extractConfig2( $info, $dir );
+ } else {
+ // $version === 1
+ $this->extractConfig1( $info );
+ }
+
if ( $version === 2 ) {
$this->extractAttributes( $path, $info );
}
}
public function getRequirements( array $info ) {
- return isset( $info['requires'] ) ? $info['requires'] : [];
+ return $info['requires'] ?? [];
}
protected function extractHooks( array $info ) {
}
protected function extractResourceLoaderModules( $dir, array $info ) {
- $defaultPaths = isset( $info['ResourceFileModulePaths'] )
- ? $info['ResourceFileModulePaths']
- : false;
+ $defaultPaths = $info['ResourceFileModulePaths'] ?? false;
if ( isset( $defaultPaths['localBasePath'] ) ) {
if ( $defaultPaths['localBasePath'] === '' ) {
// Avoid double slashes (e.g. /extensions/Example//path)
protected function extractCredits( $path, array $info ) {
$credits = [
'path' => $path,
- 'type' => isset( $info['type'] ) ? $info['type'] : 'other',
+ 'type' => $info['type'] ?? 'other',
];
foreach ( self::$creditsAttributes as $attr ) {
if ( isset( $info[$attr] ) ) {
}
foreach ( $info['config'] as $key => $val ) {
if ( $key[0] !== '@' ) {
- $this->addConfigGlobal( "$prefix$key", $val );
+ $this->addConfigGlobal( "$prefix$key", $val, $info['name'] );
}
}
}
if ( isset( $data['path'] ) && $data['path'] ) {
$value = "$dir/$value";
}
- $this->addConfigGlobal( "$prefix$key", $value );
+ $this->addConfigGlobal( "$prefix$key", $value, $info['name'] );
}
}
}
*
* @param string $key The config key with the prefix and anything
* @param mixed $value The value of the config
+ * @param string $extName Name of the extension
*/
- private function addConfigGlobal( $key, $value ) {
+ private function addConfigGlobal( $key, $value, $extName ) {
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." );
+ "The configuration setting '$key' was already set by MediaWiki core or"
+ . " another extension, and cannot be set again by $extName." );
}
$this->globals[$key] = $value;
}