X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fregistration%2FVersionChecker.php;h=1569e088b8280bcb09a47e64aea60f1c3ff1eb41;hb=153ade3fb6a93162dabb3be8ea7fcd3289cc88d8;hp=02e3a7c8ab7dc39ef42245a78413f18733334a55;hpb=220bda9175a18458449e9d754fb48830c1f76f25;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/registration/VersionChecker.php b/includes/registration/VersionChecker.php index 02e3a7c8ab..1569e088b8 100644 --- a/includes/registration/VersionChecker.php +++ b/includes/registration/VersionChecker.php @@ -110,13 +110,18 @@ class VersionChecker { case ExtensionRegistry::MEDIAWIKI_CORE: $mwError = $this->handleMediaWikiDependency( $values, $extension ); if ( $mwError !== false ) { - $errors[] = $mwError; + $errors[] = [ + 'msg' => $mwError, + 'type' => 'incompatible-core', + ]; } break; case 'extensions': - case 'skin': + case 'skins': foreach ( $values as $dependency => $constraint ) { - $extError = $this->handleExtensionDependency( $dependency, $constraint, $extension ); + $extError = $this->handleExtensionDependency( + $dependency, $constraint, $extension, $dependencyType + ); if ( $extError !== false ) { $errors[] = $extError; } @@ -164,25 +169,33 @@ class VersionChecker { * @param string $dependencyName The name of the dependency * @param string $constraint The required version constraint for this dependency * @param string $checkedExt The Extension, which depends on this dependency - * @return bool|string false for no errors, or a string message + * @param string $type Either 'extensions' or 'skins' + * @return bool|array false for no errors, or an array of info */ - private function handleExtensionDependency( $dependencyName, $constraint, $checkedExt ) { + private function handleExtensionDependency( $dependencyName, $constraint, $checkedExt, + $type + ) { // Check if the dependency is even installed if ( !isset( $this->loaded[$dependencyName] ) ) { - return "{$checkedExt} requires {$dependencyName} to be installed."; + return [ + 'msg' => "{$checkedExt} requires {$dependencyName} to be installed.", + 'type' => "missing-$type", + 'missing' => $dependencyName, + ]; + } + if ( $constraint === '*' ) { + // short-circuit since any version is OK. + return false; } // Check if the dependency has specified a version if ( !isset( $this->loaded[$dependencyName]['version'] ) ) { - // If we depend upon any version, and none is set, that's fine. - if ( $constraint === '*' ) { - wfDebug( "{$dependencyName} does not expose its version, but {$checkedExt}" - . " mentions it with constraint '*'. Assume it's ok so." ); - return false; - } else { - // Otherwise, mark it as incompatible. - return "{$dependencyName} does not expose its version, but {$checkedExt}" - . " requires: {$constraint}."; - } + $msg = "{$dependencyName} does not expose its version, but {$checkedExt}" + . " requires: {$constraint}."; + return [ + 'msg' => $msg, + 'type' => "incompatible-$type", + 'incompatible' => $checkedExt, + ]; } else { // Try to get a constraint for the dependency version try { @@ -193,16 +206,24 @@ class VersionChecker { } catch ( UnexpectedValueException $e ) { // Non-parsable version, output an error message that the version // string is invalid - return "$dependencyName does not have a valid version string."; + return [ + 'msg' => "$dependencyName does not have a valid version string.", + 'type' => 'invalid-version', + ]; } // Check if the constraint actually matches... if ( !$this->versionParser->parseConstraints( $constraint )->matches( $installedVersion ) ) { - return "{$checkedExt} is not compatible with the current " + $msg = "{$checkedExt} is not compatible with the current " . "installed version of {$dependencyName} " . "({$this->loaded[$dependencyName]['version']}), " . "it requires: " . $constraint . '.'; + return [ + 'msg' => $msg, + 'type' => "incompatible-$type", + 'incompatible' => $checkedExt, + ]; } }