X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fregistration%2FExtensionProcessor.php;h=faaaece456d6a1a65ccc9401db6c2e504003b0ad;hp=1d3fd86d8b64db0d8004208a5ba3bb6b6fd254d5;hb=c219f244b0a306dfd65f49b84fafcf7bfdf70b3a;hpb=34c498088e6f61fe8b0474450a8a66d7965d649e diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index 1d3fd86d8b..faaaece456 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -189,7 +189,6 @@ class ExtensionProcessor implements Processor { * @param string $path * @param array $info * @param int $version manifest_version for info - * @return array */ public function extractInfo( $path, array $info, $version ) { $dir = dirname( $path ); @@ -305,8 +304,76 @@ class ExtensionProcessor implements Processor { ]; } - public function getRequirements( array $info ) { - return $info['requires'] ?? []; + public function getRequirements( array $info, $includeDev ) { + // Quick shortcuts + if ( !$includeDev || !isset( $info['dev-requires'] ) ) { + return $info['requires'] ?? []; + } + + if ( !isset( $info['requires'] ) ) { + return $info['dev-requires'] ?? []; + } + + // OK, we actually have to merge everything + $merged = []; + + // Helper that combines version requirements by + // picking the non-null if one is, or combines + // the two. Note that it is not possible for + // both inputs to be null. + $pick = function ( $a, $b ) { + if ( $a === null ) { + return $b; + } elseif ( $b === null ) { + return $a; + } else { + return "$a $b"; + } + }; + + $req = $info['requires']; + $dev = $info['dev-requires']; + if ( isset( $req['MediaWiki'] ) || isset( $dev['MediaWiki'] ) ) { + $merged['MediaWiki'] = $pick( + $req['MediaWiki'] ?? null, + $dev['MediaWiki'] ?? null + ); + } + + $platform = array_merge( + array_keys( $req['platform'] ?? [] ), + array_keys( $dev['platform'] ?? [] ) + ); + if ( $platform ) { + foreach ( $platform as $pkey ) { + if ( $pkey === 'php' ) { + $value = $pick( + $req['platform']['php'] ?? null, + $dev['platform']['php'] ?? null + ); + } else { + // Prefer dev value, but these should be constant + // anyways (ext-* and ability-*) + $value = $dev['platform'][$pkey] ?? $req['platform'][$pkey]; + } + $merged['platform'][$pkey] = $value; + } + } + + foreach ( [ 'extensions', 'skins' ] as $thing ) { + $things = array_merge( + array_keys( $req[$thing] ?? [] ), + array_keys( $dev[$thing] ?? [] ) + ); + foreach ( $things as $name ) { + $merged[$thing][$name] = $pick( + $req[$thing][$name] ?? null, + $dev[$thing][$name] ?? null + ); + } + } + + return $merged; } protected function extractHooks( array $info ) {