23use Composer\Semver\VersionParser;
24use Composer\Semver\Constraint\Constraint;
79 $this->versionParser =
new VersionParser();
94 $this->loaded = $credits;
106 $this->coreVersion =
new Constraint(
111 }
catch ( UnexpectedValueException
$e ) {
124 $this->phpVersion =
new Constraint(
158 foreach ( $extDependencies
as $extension => $dependencies ) {
159 foreach ( $dependencies
as $dependencyType => $values ) {
160 switch ( $dependencyType ) {
167 if ( $mwError !==
false ) {
170 "{$extension} is not compatible with the current MediaWiki "
171 .
"core (version {$this->coreVersion->getPrettyString()}), "
172 .
"it requires: $values."
174 'type' =>
'incompatible-core',
179 foreach ( $values
as $dependency => $constraint ) {
180 if ( $dependency ===
'php' ) {
187 if ( $phpError !==
false ) {
190 "{$extension} is not compatible with the current PHP "
191 .
"version {$this->phpVersion->getPrettyString()}), "
192 .
"it requires: $constraint."
194 'type' =>
'incompatible-php',
197 } elseif ( substr( $dependency, 0, 4 ) ===
'ext-' ) {
199 $phpExtension = substr( $dependency, 4 );
200 if ( $constraint !==
'*' ) {
201 throw new UnexpectedValueException(
'Version constraints for '
202 .
'PHP extensions are not supported in ' . $extension );
204 if ( !in_array( $phpExtension, $this->phpExtensions,
true ) ) {
207 "{$extension} requires {$phpExtension} PHP extension "
210 'type' =>
'missing-phpExtension',
211 'missing' => $phpExtension,
214 } elseif ( substr( $dependency, 0, 8 ) ===
'ability-' ) {
216 $ability = substr( $dependency, 8 );
217 if ( !isset( $this->abilities[$ability] ) ) {
218 throw new UnexpectedValueException(
'Dependency type '
219 . $dependency .
' unknown in ' . $extension );
221 if ( !is_bool( $constraint ) ) {
222 throw new UnexpectedValueException(
'Only booleans are '
223 .
'allowed to to indicate the presence of abilities '
224 .
'in ' . $extension );
227 if ( $constraint ===
true &&
228 $this->abilities[$ability] !==
true
232 if ( isset( $this->abilityErrors[$ability] ) ) {
233 $customMessage =
': ' . $this->abilityErrors[$ability];
238 "{$extension} requires \"{$ability}\" ability"
241 'type' =>
'missing-ability',
242 'missing' => $ability,
247 throw new UnexpectedValueException(
'Dependency type ' . $dependency .
248 ' unknown in ' . $extension );
254 foreach ( $values
as $dependency => $constraint ) {
256 $dependency, $constraint, $extension, $dependencyType
258 if ( $extError !==
false ) {
259 $errors[] = $extError;
264 throw new UnexpectedValueException(
'Dependency type ' . $dependencyType .
265 ' unknown in ' . $extension );
283 if ( $version ===
false ) {
289 if ( $this->versionParser->parseConstraints( $constraint )
290 ->matches( $version ) ) {
310 if ( !isset( $this->loaded[$dependencyName] ) ) {
312 'msg' =>
"{$checkedExt} requires {$dependencyName} to be installed.",
313 'type' =>
"missing-$type",
314 'missing' => $dependencyName,
317 if ( $constraint ===
'*' ) {
322 if ( !isset( $this->loaded[$dependencyName][
'version'] ) ) {
323 $msg =
"{$dependencyName} does not expose its version, but {$checkedExt}"
324 .
" requires: {$constraint}.";
327 'type' =>
"incompatible-$type",
328 'incompatible' => $checkedExt,
333 $installedVersion =
new Constraint(
335 $this->versionParser->normalize( $this->loaded[$dependencyName][
'version'] )
337 }
catch ( UnexpectedValueException
$e ) {
341 'msg' =>
"$dependencyName does not have a valid version string.",
342 'type' =>
'invalid-version',
347 !$this->versionParser->parseConstraints( $constraint )->matches( $installedVersion )
349 $msg =
"{$checkedExt} is not compatible with the current "
350 .
"installed version of {$dependencyName} "
351 .
"({$this->loaded[$dependencyName]['version']}), "
352 .
"it requires: " . $constraint .
'.';
355 'type' =>
"incompatible-$type",
356 'incompatible' => $checkedExt,
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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...
string[] $abilityErrors
List of provided ability errors.
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, array $abilities=[], array $abilityErrors=[])
bool[] $abilities
List of provided abilities.
string[] $phpExtensions
List of installed PHP extensions.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
returning false will NOT prevent logging $e
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
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))