23use Composer\Semver\VersionParser;
24use Composer\Semver\Constraint\Constraint;
64 $this->versionParser =
new VersionParser();
77 $this->loaded = $credits;
89 $this->coreVersion =
new Constraint(
94 }
catch ( UnexpectedValueException
$e ) {
107 $this->phpVersion =
new Constraint(
140 foreach ( $extDependencies as $extension => $dependencies ) {
141 foreach ( $dependencies as $dependencyType => $values ) {
142 switch ( $dependencyType ) {
149 if ( $mwError !==
false ) {
152 "{$extension} is not compatible with the current MediaWiki "
153 .
"core (version {$this->coreVersion->getPrettyString()}), "
154 .
"it requires: $values."
156 'type' =>
'incompatible-core',
161 foreach ( $values as $dependency => $constraint ) {
162 if ( $dependency ===
'php' ) {
169 if ( $phpError !==
false ) {
172 "{$extension} is not compatible with the current PHP "
173 .
"version {$this->phpVersion->getPrettyString()}), "
174 .
"it requires: $constraint."
176 'type' =>
'incompatible-php',
179 } elseif ( substr( $dependency, 0, 4 ) ===
'ext-' ) {
181 $phpExtension = substr( $dependency, 4 );
182 if ( $constraint !==
'*' ) {
183 throw new UnexpectedValueException(
'Version constraints for '
184 .
'PHP extensions are not supported in ' . $extension );
186 if ( !in_array( $phpExtension, $this->phpExtensions,
true ) ) {
189 "{$extension} requires {$phpExtension} PHP extension "
192 'type' =>
'missing-phpExtension',
193 'missing' => $phpExtension,
198 throw new UnexpectedValueException(
'Dependency type ' . $dependency .
199 ' unknown in ' . $extension );
205 foreach ( $values as $dependency => $constraint ) {
207 $dependency, $constraint, $extension, $dependencyType
209 if ( $extError !==
false ) {
210 $errors[] = $extError;
215 throw new UnexpectedValueException(
'Dependency type ' . $dependencyType .
216 ' unknown in ' . $extension );
234 if ( $version ===
false ) {
240 if ( $this->versionParser->parseConstraints( $constraint )
241 ->matches( $version ) ) {
261 if ( !isset( $this->loaded[$dependencyName] ) ) {
263 'msg' =>
"{$checkedExt} requires {$dependencyName} to be installed.",
264 'type' =>
"missing-$type",
265 'missing' => $dependencyName,
268 if ( $constraint ===
'*' ) {
273 if ( !isset( $this->loaded[$dependencyName][
'version'] ) ) {
274 $msg =
"{$dependencyName} does not expose its version, but {$checkedExt}"
275 .
" requires: {$constraint}.";
278 'type' =>
"incompatible-$type",
279 'incompatible' => $checkedExt,
284 $installedVersion =
new Constraint(
286 $this->versionParser->normalize( $this->loaded[$dependencyName][
'version'] )
288 }
catch ( UnexpectedValueException
$e ) {
292 'msg' =>
"$dependencyName does not have a valid version string.",
293 'type' =>
'invalid-version',
298 !$this->versionParser->parseConstraints( $constraint )->matches( $installedVersion )
300 $msg =
"{$checkedExt} is not compatible with the current "
301 .
"installed version of {$dependencyName} "
302 .
"({$this->loaded[$dependencyName]['version']}), "
303 .
"it requires: " . $constraint .
'.';
306 'type' =>
"incompatible-$type",
307 'incompatible' => $checkedExt,
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.
handleDependency( $version, $constraint, $checkedExt)
Handle a simple dependency to MediaWiki core or PHP.
checkArray(array $extDependencies)
Check all given dependencies if they are compatible with the named installed extensions in the $credi...
Constraint bool $phpVersion
representing PHP version
array $loaded
Loaded extensions.
VersionParser $versionParser
setCoreVersion( $coreVersion)
Set MediaWiki core version.
setPhpVersion( $phpVersion)
Set PHP version.
__construct( $coreVersion, $phpVersion, array $phpExtensions)
string[] $phpExtensions
List of installed PHP extensions.
returning false will NOT prevent logging $e
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))