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 ) {
115 'type' =>
'incompatible-core',
121 foreach ( $values as $dependency => $constraint ) {
123 $dependency, $constraint, $extension, $dependencyType
125 if ( $extError !==
false ) {
126 $errors[] = $extError;
131 throw new UnexpectedValueException(
'Dependency type ' . $dependencyType .
132 ' unknown in ' . $extension );
150 if ( $this->coreVersion ===
false ) {
156 if ( $this->versionParser->parseConstraints( $constraint )
157 ->matches( $this->coreVersion ) ) {
161 return "{$checkedExt} is not compatible with the current "
162 .
"MediaWiki core (version {$this->coreVersion->getPrettyString()}), it requires: "
179 if ( !isset( $this->loaded[$dependencyName] ) ) {
181 'msg' =>
"{$checkedExt} requires {$dependencyName} to be installed.",
182 'type' =>
"missing-$type",
183 'missing' => $dependencyName,
187 if ( !isset( $this->loaded[$dependencyName][
'version'] ) ) {
189 if ( $constraint ===
'*' ) {
190 wfDebug(
"{$dependencyName} does not expose its version, but {$checkedExt}"
191 .
" mentions it with constraint '*'. Assume it's ok so." );
195 $msg =
"{$dependencyName} does not expose its version, but {$checkedExt}"
196 .
" requires: {$constraint}.";
199 'type' =>
"incompatible-$type",
200 'incompatible' => $checkedExt,
206 $installedVersion =
new Constraint(
208 $this->versionParser->normalize( $this->loaded[$dependencyName][
'version'] )
210 }
catch ( UnexpectedValueException
$e ) {
214 'msg' =>
"$dependencyName does not have a valid version string.",
215 'type' =>
'invalid-version',
220 !$this->versionParser->parseConstraints( $constraint )->matches( $installedVersion )
222 $msg =
"{$checkedExt} is not compatible with the current "
223 .
"installed version of {$dependencyName} "
224 .
"({$this->loaded[$dependencyName]['version']}), "
225 .
"it requires: " . $constraint .
'.';
228 'type' =>
"incompatible-$type",
229 'incompatible' => $checkedExt,
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, $type)
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