23 require_once __DIR__ .
'/Maintenance.php';
35 parent::__construct();
37 $this->
addOption(
'extensions',
'Comma separated list of extensions to check',
false,
true );
38 $this->
addOption(
'skins',
'Comma separated list of skins to check',
false,
true );
39 $this->
addOption(
'json',
'Output in JSON' );
40 $this->
addOption(
'dev',
'Check development dependencies too' );
44 $this->checkDev = $this->
hasOption(
'dev' );
45 $extensions = $this->
hasOption(
'extensions' )
46 ? explode(
',', $this->
getOption(
'extensions' ) )
49 ? explode(
',', $this->
getOption(
'skins' ) )
56 foreach ( $extensions as $extension ) {
57 if ( !$this->checkDev && $registry->isLoaded( $extension ) ) {
62 $this->
loadThing( $dependencies, $extension, [ $extension ], [] );
65 foreach ( $skins as $skin ) {
66 if ( !$this->checkDev && $registry->isLoaded( $skin ) ) {
71 $this->
loadThing( $dependencies, $skin, [], [ $skin ] );
75 $this->
output( json_encode( $dependencies ) .
"\n" );
81 private function loadThing( &$dependencies, $name, $extensions, $skins ) {
82 $extDir = $this->
getConfig()->get(
'ExtensionDirectory' );
83 $styleDir = $this->
getConfig()->get(
'StyleDirectory' );
86 foreach ( $extensions as $extension ) {
87 $path =
"$extDir/$extension/extension.json";
88 if ( file_exists(
$path ) ) {
98 foreach ( $skins as $skin ) {
99 $path =
"$styleDir/$skin/skin.json";
100 if ( file_exists(
$path ) ) {
115 $registry->setCheckDevRequires( $this->checkDev );
117 $registry->readFromQueue(
$queue );
120 if ( $e->incompatibleCore ) {
121 $reason =
'incompatible-core';
122 } elseif ( $e->incompatibleSkins ) {
123 $reason =
'incompatible-skins';
124 } elseif ( $e->incompatibleExtensions ) {
125 $reason =
'incompatible-extensions';
126 } elseif ( $e->missingExtensions || $e->missingSkins ) {
132 array_merge( $extensions, $e->missingExtensions ),
133 array_merge( $skins, $e->missingSkins )
142 $this->
addToDependencies( $dependencies, $extensions, $skins, $name, $reason, $e->getMessage() );
149 $why =
null,
$status =
null, $message =
null
152 $iter = [
'extensions' => $extensions,
'skins' => $skins ];
153 foreach ( $iter as
$type => $things ) {
154 foreach ( $things as $thing ) {
155 $preStatus = $dependencies[
$type][$thing][
'status'] ??
false;
156 if ( $preStatus !==
'loaded' ) {
161 $tStatus = $mainRegistry->isLoaded( $thing ) ?
'loaded' :
'present';
163 $dependencies[
$type][$thing][
'status'] = $tStatus;
165 if ( $why !==
null ) {
166 $dependencies[
$type][$thing][
'why'][] = $why;
168 $dependencies[
$type][$thing][
'why'] = array_unique(
169 $dependencies[
$type][$thing][
'why'] );
172 if ( $message !==
null ) {
173 $dependencies[
$type][$thing][
'message'] = trim( $message );
182 foreach ( $dependencies as
$type => $things ) {
183 $text .= ucfirst(
$type ) .
"\n" . str_repeat(
'=', strlen(
$type ) ) .
"\n";
184 foreach ( $things as $thing => $info ) {
185 $why = $info[
'why'] ?? [];
187 $whyText =
'(because: ' . implode(
',', $why ) .
') ';
191 $msg = isset( $info[
'message'] ) ?
", {$info['message']}" :
'';
193 $text .=
"$thing: {$info['status']}{$msg} $whyText\n";
198 return trim( $text );