76 $coreVersion, $phpVersion, array $phpExtensions,
77 array $abilities = [], array $abilityErrors = []
79 $this->versionParser =
new VersionParser();
80 $this->setCoreVersion( $coreVersion );
81 $this->setPhpVersion( $phpVersion );
82 $this->phpExtensions = $phpExtensions;
83 $this->abilities = $abilities;
84 $this->abilityErrors = $abilityErrors;
156 foreach ( $extDependencies as $extension => $dependencies ) {
157 foreach ( $dependencies as $dependencyType => $values ) {
158 switch ( $dependencyType ) {
159 case ExtensionRegistry::MEDIAWIKI_CORE:
160 $mwError = $this->handleDependency(
164 if ( $mwError !==
false ) {
167 "{$extension} is not compatible with the current MediaWiki "
168 .
"core (version {$this->coreVersion->getPrettyString()}), "
169 .
"it requires: $values.",
170 'type' =>
'incompatible-core',
175 foreach ( $values as $dependency => $constraint ) {
176 if ( $dependency ===
'php' ) {
178 $phpError = $this->handleDependency(
182 if ( $phpError !==
false ) {
185 "{$extension} is not compatible with the current PHP "
186 .
"version {$this->phpVersion->getPrettyString()}), "
187 .
"it requires: $constraint.",
188 'type' =>
'incompatible-php',
191 } elseif ( substr( $dependency, 0, 4 ) ===
'ext-' ) {
193 $phpExtension = substr( $dependency, 4 );
194 if ( $constraint !==
'*' ) {
195 throw new UnexpectedValueException(
'Version constraints for '
196 .
'PHP extensions are not supported in ' . $extension );
198 if ( !in_array( $phpExtension, $this->phpExtensions,
true ) ) {
201 "{$extension} requires {$phpExtension} PHP extension "
202 .
"to be installed.",
203 'type' =>
'missing-phpExtension',
204 'missing' => $phpExtension,
207 } elseif ( substr( $dependency, 0, 8 ) ===
'ability-' ) {
209 $ability = substr( $dependency, 8 );
210 if ( !isset( $this->abilities[$ability] ) ) {
211 throw new UnexpectedValueException(
'Dependency type '
212 . $dependency .
' unknown in ' . $extension );
214 if ( !is_bool( $constraint ) ) {
215 throw new UnexpectedValueException(
'Only booleans are '
216 .
'allowed to to indicate the presence of abilities '
217 .
'in ' . $extension );
221 $this->abilities[$ability] !==
true
225 if ( isset( $this->abilityErrors[$ability] ) ) {
226 $customMessage =
': ' . $this->abilityErrors[$ability];
231 "{$extension} requires \"{$ability}\" ability"
233 'type' =>
'missing-ability',
234 'missing' => $ability,
239 throw new UnexpectedValueException(
'Dependency type ' . $dependency .
240 ' unknown in ' . $extension );
246 foreach ( $values as $dependency => $constraint ) {
247 $extError = $this->handleExtensionDependency(
248 $dependency, $constraint, $extension, $dependencyType
250 if ( $extError !==
false ) {
251 $errors[] = $extError;
256 throw new UnexpectedValueException(
'Dependency type ' . $dependencyType .
257 ' unknown in ' . $extension );
297 private function handleExtensionDependency( $dependencyName, $constraint, $checkedExt,