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."
171 'type' =>
'incompatible-core',
176 foreach ( $values as $dependency => $constraint ) {
177 if ( $dependency ===
'php' ) {
179 $phpError = $this->handleDependency(
183 if ( $phpError !==
false ) {
186 "{$extension} is not compatible with the current PHP "
187 .
"version {$this->phpVersion->getPrettyString()}), "
188 .
"it requires: $constraint."
190 'type' =>
'incompatible-php',
193 } elseif ( substr( $dependency, 0, 4 ) ===
'ext-' ) {
195 $phpExtension = substr( $dependency, 4 );
196 if ( $constraint !==
'*' ) {
197 throw new UnexpectedValueException(
'Version constraints for '
198 .
'PHP extensions are not supported in ' . $extension );
200 if ( !in_array( $phpExtension, $this->phpExtensions,
true ) ) {
203 "{$extension} requires {$phpExtension} PHP extension "
206 'type' =>
'missing-phpExtension',
207 'missing' => $phpExtension,
210 } elseif ( substr( $dependency, 0, 8 ) ===
'ability-' ) {
212 $ability = substr( $dependency, 8 );
213 if ( !isset( $this->abilities[$ability] ) ) {
214 throw new UnexpectedValueException(
'Dependency type '
215 . $dependency .
' unknown in ' . $extension );
217 if ( !is_bool( $constraint ) ) {
218 throw new UnexpectedValueException(
'Only booleans are '
219 .
'allowed to to indicate the presence of abilities '
220 .
'in ' . $extension );
224 $this->abilities[$ability] !==
true
228 if ( isset( $this->abilityErrors[$ability] ) ) {
229 $customMessage =
': ' . $this->abilityErrors[$ability];
234 "{$extension} requires \"{$ability}\" ability"
237 'type' =>
'missing-ability',
238 'missing' => $ability,
243 throw new UnexpectedValueException(
'Dependency type ' . $dependency .
244 ' unknown in ' . $extension );
250 foreach ( $values as $dependency => $constraint ) {
251 $extError = $this->handleExtensionDependency(
252 $dependency, $constraint, $extension, $dependencyType
254 if ( $extError !==
false ) {
255 $errors[] = $extError;
260 throw new UnexpectedValueException(
'Dependency type ' . $dependencyType .
261 ' unknown in ' . $extension );
301 private function handleExtensionDependency( $dependencyName, $constraint, $checkedExt,