X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28?a=blobdiff_plain;f=includes%2Fregistration%2FVersionChecker.php;h=9c673bc5db1aea6f03be38c541c09a596e69b2c9;hb=c8833d8e8ecc1b60f289f5c1ffdb15b2f6d44f8b;hp=5aaaa1b8ab9eca959339fe9202f463c29ee4b052;hpb=8bb5a6c461c31ee5ce6874548246fc2c520686f6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/registration/VersionChecker.php b/includes/registration/VersionChecker.php index 5aaaa1b8ab..9c673bc5db 100644 --- a/includes/registration/VersionChecker.php +++ b/includes/registration/VersionChecker.php @@ -87,17 +87,17 @@ class VersionChecker { * installed extensions in the $credits array. * * Example $extDependencies: - * { - * 'FooBar' => { - * 'MediaWiki' => '>= 1.25.0', - * 'extensions' => { - * 'FooBaz' => '>= 1.25.0' - * }, - * 'skins' => { - * 'BazBar' => '>= 1.0.0' - * } - * } - * } + * { + * 'FooBar' => { + * 'MediaWiki' => '>= 1.25.0', + * 'extensions' => { + * 'FooBaz' => '>= 1.25.0' + * }, + * 'skins' => { + * 'BazBar' => '>= 1.0.0' + * } + * } + * } * * @param array $extDependencies All extensions that depend on other ones * @return array @@ -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': foreach ( $values as $dependency => $constraint ) { - $extError = $this->handleExtensionDependency( $dependency, $constraint, $extension ); + $extError = $this->handleExtensionDependency( + $dependency, $constraint, $extension, $dependencyType + ); if ( $extError !== false ) { $errors[] = $extError; } @@ -164,24 +169,36 @@ 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 'extension' or 'skin' + * @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, + ]; } // 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 it's version, but {$checkedExt} - mentions it with constraint '*'. Assume it's ok so." ); + 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 it's 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 @@ -193,16 +210,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, + ]; } }