23use Composer\Semver\VersionParser;
24use Composer\Semver\Constraint\Constraint;
52 $this->versionParser =
new VersionParser();
63 $this->loaded = $credits;
75 $this->coreVersion =
new Constraint(
80 }
catch ( UnexpectedValueException
$e ) {
107 foreach ( $extDependencies as $extension => $dependencies ) {
108 foreach ( $dependencies as $dependencyType => $values ) {
109 switch ( $dependencyType ) {
112 if ( $mwError !==
false ) {
113 $errors[] = $mwError;
118 foreach ( $values as $dependency => $constraint ) {
120 if ( $extError !==
false ) {
121 $errors[] = $extError;
126 throw new UnexpectedValueException(
'Dependency type ' . $dependencyType .
127 ' unknown in ' . $extension );
145 if ( $this->coreVersion ===
false ) {
151 if ( $this->versionParser->parseConstraints( $constraint )
152 ->matches( $this->coreVersion ) ) {
156 return "{$checkedExt} is not compatible with the current "
157 .
"MediaWiki core (version {$this->coreVersion->getPrettyString()}), it requires: "
171 if ( !isset( $this->loaded[$dependencyName] ) ) {
172 return "{$checkedExt} requires {$dependencyName} to be installed.";
175 if ( !isset( $this->loaded[$dependencyName][
'version'] ) ) {
177 if ( $constraint ===
'*' ) {
178 wfDebug(
"{$dependencyName} does not expose it's version, but {$checkedExt}
179 mentions it with constraint '*'. Assume it's ok so." );
183 return "{$dependencyName} does not expose it's version, but {$checkedExt}
184 requires: {$constraint}.";
189 $installedVersion =
new Constraint(
191 $this->versionParser->normalize( $this->loaded[$dependencyName][
'version'] )
193 }
catch ( UnexpectedValueException
$e ) {
196 return "$dependencyName does not have a valid version string.";
200 !$this->versionParser->parseConstraints( $constraint )->matches( $installedVersion )
202 return "{$checkedExt} is not compatible with the current "
203 .
"installed version of {$dependencyName} "
204 .
"({$this->loaded[$dependencyName]['version']}), "
205 .
"it requires: " . $constraint .
'.';
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
const MEDIAWIKI_CORE
"requires" key that applies to MediaWiki core/$wgVersion
Provides functions to check a set of extensions with dependencies against a set of loaded extensions ...
handleExtensionDependency( $dependencyName, $constraint, $checkedExt)
Handle a dependency to another extension.
Constraint bool $coreVersion
representing $wgVersion
setLoadedExtensionsAndSkins(array $credits)
Set an array with credits of all loaded extensions and skins.
checkArray(array $extDependencies)
Check all given dependencies if they are compatible with the named installed extensions in the $credi...
array $loaded
Loaded extensions.
VersionParser $versionParser
handleMediaWikiDependency( $constraint, $checkedExt)
Handle a dependency to MediaWiki core.
__construct( $coreVersion)
setCoreVersion( $coreVersion)
Set MediaWiki core version.
returning false will NOT prevent logging $e