9namespace MediaWiki\Specials;
12use MediaWiki\Config\Config;
13use MediaWiki\HookContainer\HookRunner;
14use MediaWiki\Html\Html;
15use MediaWiki\Html\TocGeneratorTrait;
16use MediaWiki\Language\Language;
17use MediaWiki\Language\RawMessage;
18use MediaWiki\MainConfigNames;
19use MediaWiki\MediaWikiServices;
20use MediaWiki\Message\Message;
21use MediaWiki\Parser\ParserFactory;
22use MediaWiki\Parser\Sanitizer;
23use MediaWiki\Registration\ExtensionRegistry;
24use MediaWiki\SpecialPage\SpecialPage;
25use MediaWiki\Utils\ExtensionInfo;
26use MediaWiki\Utils\GitInfo;
27use MediaWiki\Utils\MWTimestamp;
28use MediaWiki\Utils\UrlUtils;
29use Symfony\Component\Yaml\Yaml;
30use Wikimedia\Composer\ComposerInstalled;
31use Wikimedia\HtmlArmor\HtmlArmor;
32use Wikimedia\Rdbms\IConnectionProvider;
40 use TocGeneratorTrait;
57 parent::__construct(
'Version' );
70 $credits[$credit[
'type']][] = $credit;
85 $out->getMetadata()->setPreventClickjacking(
false );
88 $parts = explode(
'/', (
string)$par );
90 if ( isset( $parts[1] ) ) {
91 $extName = str_replace(
'_',
' ', $parts[1] );
93 foreach ( $credits as $extensions ) {
94 foreach ( $extensions as $ext ) {
95 if ( isset( $ext[
'name'] ) && ( $ext[
'name'] === $extName ) ) {
102 $out->setStatusCode( 404 );
105 $extName =
'MediaWiki';
109 $extNotFound = $extNode ===
null && $extName !==
'MediaWiki';
112 switch ( strtolower( $parts[0] ) ) {
114 $out->addModuleStyles(
'mediawiki.special' );
116 $wikiText =
'{{int:version-credits-not-found}}';
117 if ( $extName ===
'MediaWiki' ) {
118 $wikiText = file_get_contents( MW_INSTALL_PATH .
'/CREDITS' );
120 $wikiText = str_replace(
121 [
'<!-- BEGIN CONTRIBUTOR LIST -->',
'<!-- END CONTRIBUTOR LIST -->' ],
122 [
'<div class="mw-version-credits">',
'</div>' ],
125 } elseif ( ( $extNode !==
null ) && isset( $extNode[
'path'] ) ) {
126 $file = ExtensionInfo::getAuthorsFileName( dirname( $extNode[
'path'] ) );
128 $wikiText = file_get_contents( $file );
129 if ( str_ends_with( $file,
'.txt' ) ) {
142 $out->setPageTitleMsg( $this->
msg(
'version-credits-title' )->plaintextParams( $extName ) );
143 if ( $extNotFound ) {
144 $out->addHTML( $this->
msg(
'version-ext-not-found' )->plaintextParams( $extName )->parseAsBlock() );
146 $out->addWikiTextAsInterface( $wikiText );
151 $out->setPageTitleMsg( $this->
msg(
'version-license-title' )->plaintextParams( $extName ) );
153 $licenseFound =
false;
155 if ( $extName ===
'MediaWiki' ) {
156 $license = file_get_contents( MW_INSTALL_PATH .
'/COPYING' );
157 $license = str_replace(
159 '[[Special:Version/Credits|CREDITS file]]',
162 $out->addWikiTextAsInterface( $license );
163 $licenseFound =
true;
164 } elseif ( ( $extNode !==
null ) && isset( $extNode[
'path'] ) ) {
165 $files = ExtensionInfo::getLicenseFileNames( dirname( $extNode[
'path'] ) );
167 $licenseFound =
true;
168 foreach ( $files as $file ) {
169 $out->addWikiTextAsInterface(
176 file_get_contents( $file )
182 if ( $extNotFound ) {
183 $out->addHTML( $this->
msg(
'version-ext-not-found' )->plaintextParams( $extName )->parseAsBlock() );
184 } elseif ( !$licenseFound ) {
185 $out->addWikiTextAsInterface(
'{{int:version-license-not-found}}' );
190 $out->addModuleStyles(
'mediawiki.special' );
193 if ( $this->
getUser()->isNamed() ) {
194 $out->addModuleStyles(
'mediawiki.htmlform.codex.styles' );
195 $out->addModules(
'mediawiki.misc-authed-ooui' );
199 'id' =>
'mw-version-sbom-download',
200 'class' =>
'cdx-button cdx-button--fake-button cdx-button--fake-button--enabled',
204 'meta' =>
'siteinfo',
207 'formatversion' =>
'2',
209 'download' =>
'sbom.cdx.json',
211 $this->
msg(
'version-download-sbom' )->text()
215 $out->addHTML( $this->getMediaWikiCredits() );
219 $this->softwareInformation(),
221 $this->getSkinCredits( $credits ),
222 $this->getExtensionCredits( $credits ),
231 $out->addTOCPlaceholder( $this->getTocData() );
234 foreach ( $sections as $content ) {
235 $out->addHTML( $content );
247 private function getMediaWikiCredits() {
252 [
'id' =>
'mw-version-license' ],
253 $this->msg(
'version-license' )->text()
256 $ret .= Html::rawElement(
'div', [
'class' =>
'plainlinks' ],
257 $this->msg(
new RawMessage( self::getCopyrightAndAuthorList() ) )->parseAsBlock() .
258 Html::rawElement(
'div', [
'class' =>
'mw-version-license-info' ],
259 $this->msg(
'version-license-info' )->parseAsBlock()
273 if ( defined(
'MEDIAWIKI_INSTALL' ) ) {
274 $othersLink =
'[https://www.mediawiki.org/wiki/Special:Version/Credits ' .
275 wfMessage(
'version-poweredby-others' )->plain() .
']';
277 $othersLink =
'[[Special:Version/Credits|' .
278 wfMessage(
'version-poweredby-others' )->plain() .
']]';
281 $translatorsLink =
'[https://translatewiki.net/wiki/Translating:MediaWiki/Credits ' .
282 wfMessage(
'version-poweredby-translators' )->plain() .
']';
285 'Magnus Manske',
'Brooke Vibber',
'Lee Daniel Crocker',
286 'Tim Starling',
'Erik Möller',
'Gabriel Wicke',
'Ævar Arnfjörð Bjarmason',
287 'Niklas Laxström',
'Domas Mituzas',
'Rob Church',
'Yuri Astrakhan',
288 'Aryeh Gregor',
'Aaron Schulz',
'Andrew Garrett',
'Raimond Spekking',
289 'Alexandre Emsenhuber',
'Siebrand Mazeland',
'Chad Horohoe',
290 'Roan Kattouw',
'Trevor Parscal',
'Bryan Tong Minh',
'Sam Reed',
291 'Victor Vasiliev',
'Rotem Liss',
'Platonides',
'Antoine Musso',
292 'Timo Tijhof',
'Daniel Kinzler',
'Jeroen De Dauw',
'Brad Jorsch',
293 'Bartosz Dziewoński',
'Ed Sanders',
'Moriel Schottlender',
294 'Kunal Mehta',
'James D. Forrester',
'Brian Wolff',
'Adam Shorland',
295 'DannyS712',
'Ori Livneh',
'Max Semenik',
'Amir Sarabadani',
296 'Derk-Jan Hartman',
'Petr Pchelko',
'Umherirrender',
'C. Scott Ananian',
297 'fomafix',
'Thiemo Kreuz',
'Gergő Tisza',
'Volker E.',
298 'Jack Phoenix',
'Isarra Yos',
299 $othersLink, $translatorsLink
302 return Html::rawElement(
304 [
'id' =>
'mw-version-poweredby-credits' ],
306 'version-poweredby-credits',
307 MWTimestamp::getLocalInstance()->format(
'Y' ),
318 private function getSoftwareInformation() {
319 $dbr = $this->dbProvider->getReplicaDatabase();
324 $versionLink = $this->getVersionLinkedGit() ?:
MW_VERSION;
326 '[https://www.mediawiki.org/ MediaWiki]' => $versionLink,
327 '[https://php.net/ PHP]' => PHP_VERSION .
" (" . PHP_SAPI .
")",
328 '[https://icu.unicode.org/ ICU]' => INTL_ICU_VERSION,
329 $dbr->getSoftwareLink() => $dbr->getServerInfo(),
333 if ( phpversion(
"wikidiff2" ) ) {
334 $software[
'[https://www.mediawiki.org/wiki/Wikidiff2 wikidiff2]' ] = phpversion(
"wikidiff2" );
338 $this->getHookRunner()->onSoftwareInfo( $software );
348 private function softwareInformation() {
349 $this->addTocSection(
id:
'mw-version-software', msg:
'version-software' );
353 [
'id' =>
'mw-version-software' ],
354 $this->msg(
'version-software' )->text()
357 $out .= Html::openElement(
'table', [
'class' =>
'wikitable plainlinks',
'id' =>
'sv-software' ] );
359 $out .= $this->getTableHeaderHtml( [
360 $this->msg(
'version-software-product' )->text(),
361 $this->msg(
'version-software-version' )->text()
364 foreach ( $this->getSoftwareInformation() as $name => $version ) {
365 $out .= Html::rawElement(
368 Html::rawElement(
'td', [], $this->msg(
new RawMessage( $name ) )->parse() ) .
369 Html::rawElement(
'td', [
'dir' =>
'ltr' ], $this->msg(
new RawMessage( $version ) )->parse() )
373 $out .= Html::closeElement(
'table' );
387 public static function getVersion( $flags =
'', $lang =
null ) {
388 $gitInfo = GitInfo::repo()->getHeadSHA1();
391 } elseif ( $flags ===
'nodb' ) {
392 $shortSha1 = substr( $gitInfo, 0, 7 );
395 $shortSha1 = substr( $gitInfo, 0, 7 );
397 if ( $lang !==
null ) {
398 $msg->inLanguage( $lang );
400 $shortSha1 = $msg->params( $shortSha1 )->text();
407 private function getMWVersionLinked(): string {
409 if ( $this->getHookRunner()->onSpecialVersionVersionUrl(
MW_VERSION, $versionUrl ) ) {
411 preg_match(
"/^(\d+\.\d+)/",
MW_VERSION, $versionParts );
412 $versionUrl =
"https://www.mediawiki.org/wiki/MediaWiki_{$versionParts[1]}";
415 return '[' . $versionUrl .
' ' .
MW_VERSION .
']';
423 private function getVersionLinkedGit(): bool|string {
424 $gitInfo = new GitInfo( MW_INSTALL_PATH );
425 $headSHA1 = $gitInfo->getHeadSHA1();
430 $shortSHA1 =
'(' . substr( $headSHA1, 0, 7 ) .
')';
432 $gitHeadUrl = $gitInfo->getHeadViewUrl();
433 if ( $gitHeadUrl !==
false ) {
434 $shortSHA1 =
"[$gitHeadUrl $shortSHA1]";
437 $gitHeadCommitDate = $gitInfo->getHeadCommitDate();
438 if ( $gitHeadCommitDate ) {
439 $shortSHA1 .= Html::element(
'br' );
440 $shortSHA1 .= $this->
getLanguage()->timeanddate( (
string)$gitHeadCommitDate,
true );
443 return $this->getMWVersionLinked() .
" $shortSHA1";
457 self::$extensionTypes = [
458 'specialpage' =>
wfMessage(
'version-specialpages' )->text(),
459 'editor' =>
wfMessage(
'version-editors' )->text(),
460 'wikifamily' =>
wfMessage(
'version-wikifamily' )->text(),
461 'parserhook' =>
wfMessage(
'version-parserhooks' )->text(),
462 'variable' =>
wfMessage(
'version-variables' )->text(),
463 'media' =>
wfMessage(
'version-mediahandlers' )->text(),
464 'antispam' =>
wfMessage(
'version-antispam' )->text(),
465 'skin' =>
wfMessage(
'version-skins' )->text(),
466 'api' =>
wfMessage(
'version-api' )->text(),
467 'other' =>
wfMessage(
'version-other' )->text(),
471 ->onExtensionTypes( self::$extensionTypes );
474 return self::$extensionTypes;
483 private function getExtensionCredits( array $credits ) {
484 $extensionTypes = self::getExtensionTypes();
486 $this->addTocSection(
id:
'mw-version-ext', msg:
'version-extensions' );
490 [
'id' =>
'mw-version-ext' ],
491 $this->msg(
'version-extensions' )->text()
497 ( count( $credits ) === 1 && isset( $credits[
'skin'] ) )
502 $this->msg(
'version-extensions-no-ext' )->text()
509 $credits[
'other'] ??= [];
510 foreach ( $credits as $type => $extensions ) {
511 if ( !array_key_exists( $type, $extensionTypes ) ) {
512 $credits[
'other'] = array_merge( $credits[
'other'], $extensions );
517 foreach ( $extensionTypes as $type => $text ) {
519 if ( $type !==
'other' && $type !==
'skin' ) {
520 $out .= $this->getExtensionCategory( $type, $text, $credits[$type] ?? [] );
525 $out .= $this->getExtensionCategory(
'other', $extensionTypes[
'other'], $credits[
'other'] );
536 private function getSkinCredits( array $credits ) {
537 $this->
addTocSection(
id:
'mw-version-skin', msg:
'version-skins' );
539 $out = Html::element(
541 [
'id' =>
'mw-version-skin' ],
542 $this->
msg(
'version-skins' )->text()
545 if ( !isset( $credits[
'skin'] ) || !$credits[
'skin'] ) {
546 $out .= Html::element(
549 $this->
msg(
'version-skins-no-skin' )->text()
554 $out .= $this->getExtensionCategory(
'skin',
null, $credits[
'skin'] );
566 $this->addTocSection(
id:
'mw-version-libraries',
msg:
'version-libraries' );
570 [
'id' =>
'mw-version-libraries' ],
571 $this->
msg(
'version-libraries' )->text()
576 . $this->getClientSideLibraries();
587 MW_INSTALL_PATH .
'/vendor/composer/installed.json'
592 if ( !isset( $credits[$type] ) || $credits[$type] === [] ) {
595 foreach ( $credits[$type] as $extension ) {
596 if ( !isset( $extension[
'path'] ) ) {
599 $paths[] = dirname( $extension[
'path'] ) .
'/vendor/composer/installed.json';
605 foreach ( $paths as
$path ) {
606 if ( !file_exists(
$path ) ) {
612 $dependencies += $installed->getInstalledDependencies();
615 ksort( $dependencies );
616 return $dependencies;
626 $dependencies = self::parseComposerInstalled( $credits );
627 if ( $dependencies === [] ) {
631 $this->addTocSubSection(
id:
'mw-version-libraries-server',
msg:
'version-libraries-server' );
635 [
'id' =>
'mw-version-libraries-server' ],
636 $this->
msg(
'version-libraries-server' )->text()
638 $out .= Html::openElement(
640 [
'class' =>
'wikitable plainlinks mw-installed-software',
'id' =>
'sv-libraries' ]
643 $out .= $this->getTableHeaderHtml( [
644 $this->
msg(
'version-libraries-library' )->text(),
645 $this->
msg(
'version-libraries-version' )->text(),
646 $this->
msg(
'version-libraries-license' )->text(),
647 $this->
msg(
'version-libraries-description' )->text(),
648 $this->
msg(
'version-libraries-authors' )->text(),
651 foreach ( $dependencies as $name => $info ) {
652 if ( !is_array( $info ) || str_starts_with( $info[
'type'],
'mediawiki-' ) ) {
657 $authors = array_map(
static function ( $arr ) {
658 return new HtmlArmor( isset( $arr[
'homepage'] ) ?
659 Html::element(
'a', [
'href' => $arr[
'homepage'] ], $arr[
'name'] ) :
660 htmlspecialchars( $arr[
'name'] )
662 }, $info[
'authors'] );
663 $authors = $this->
listAuthors( $authors,
false, MW_INSTALL_PATH .
"/vendor/$name" );
668 $out .= Html::openElement(
'tr', [
671 'id' => Sanitizer::escapeIdForAttribute(
672 "mw-version-library-$name"
678 "https://packagist.org/packages/$name",
682 [
'class' =>
'mw-version-library-name' ]
685 .
Html::element(
'td', [
'dir' =>
'auto' ], $info[
'version'] )
686 .
Html::element(
'td', [
'dir' =>
'auto' ], $this->listToText( $info[
'licenses'] ) )
687 .
Html::element(
'td', [
'lang' =>
'en',
'dir' =>
'ltr' ], $info[
'description'] )
688 . Html::rawElement(
'td', [], $authors )
689 . Html::closeElement(
'tr' );
691 $out .= Html::closeElement(
'table' );
702 $registryDirs = [
'MediaWiki' => MW_INSTALL_PATH .
'/resources/lib' ]
703 + ExtensionRegistry::getInstance()->getAttribute(
'ForeignResourcesDir' );
706 foreach ( $registryDirs as
$source => $registryDir ) {
707 $foreignResources = Yaml::parseFile(
"$registryDir/foreign-resources.yaml" );
708 foreach ( $foreignResources as $name => $module ) {
709 $key = $name . $module[
'version'];
710 if ( isset( $modules[$key] ) ) {
711 $modules[$key][
'source'][] =
$source;
714 $modules[$key] = $module + [
'name' => $name,
'source' => [
$source ] ];
726 private function getClientSideLibraries() {
727 $this->addTocSubSection(
id:
'mw-version-libraries-client', msg:
'version-libraries-client' );
731 [
'id' =>
'mw-version-libraries-client' ],
732 $this->msg(
'version-libraries-client' )->text()
734 $out .= Html::openElement(
736 [
'class' =>
'wikitable plainlinks mw-installed-software',
'id' =>
'sv-libraries-client' ]
739 $out .= $this->getTableHeaderHtml( [
740 $this->msg(
'version-libraries-library' )->text(),
741 $this->msg(
'version-libraries-version' )->text(),
742 $this->msg(
'version-libraries-license' )->text(),
743 $this->msg(
'version-libraries-authors' )->text(),
744 $this->msg(
'version-libraries-source' )->text()
747 foreach ( self::parseForeignResources() as $name => $info ) {
751 $out .= Html::openElement(
'tr', [
754 'id' => Sanitizer::escapeIdForAttribute(
755 "mw-version-library-$name"
760 $this->getLinkRenderer()->makeExternalLink(
763 $this->getFullTitle(),
765 [
'class' =>
'mw-version-library-name' ]
768 .
Html::element(
'td', [
'dir' =>
'auto' ], $info[
'version'] )
769 .
Html::element(
'td', [
'dir' =>
'auto' ], $info[
'license'] )
770 .
Html::element(
'td', [
'dir' =>
'auto' ], $info[
'authors'] ??
'—' )
771 .
Html::element(
'td', [
'dir' =>
'auto' ], $this->listToText( $info[
'source'] ) )
772 . Html::closeElement(
'tr' );
785 $tags = $this->parserFactory->getMainInstance()->getTags();
790 $this->addTocSection(
id:
'mw-version-parser-extensiontags',
msg:
'version-parser-extensiontags' );
792 $out = Html::rawElement(
794 [
'id' =>
'mw-version-parser-extensiontags' ],
797 [
'class' =>
'plainlinks' ],
799 'https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Tag_extensions',
800 $this->
msg(
'version-parser-extensiontags' ),
806 array_walk( $tags,
static function ( &$value ) {
808 $value = Html::rawElement(
812 'style' =>
'white-space: nowrap;',
818 $out .= Html::rawElement(
820 [
'id' =>
'mw-version-parser-extensiontags-list' ],
821 $this->listToText( $tags )
833 $funcHooks = $this->parserFactory->getMainInstance()->getFunctionHooks();
838 $this->addTocSection(
id:
'mw-version-parser-function-hooks',
msg:
'version-parser-function-hooks' );
840 $out = Html::rawElement(
842 [
'id' =>
'mw-version-parser-function-hooks' ],
845 [
'class' =>
'plainlinks' ],
847 'https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Parser_functions',
848 $this->
msg(
'version-parser-function-hooks' ),
854 $funcSynonyms = $this->parserFactory->getMainInstance()->getFunctionSynonyms();
861 $preferredSynonyms = array_flip( array_reverse( $funcSynonyms[1] + $funcSynonyms[0] ) );
862 array_walk( $funcHooks,
static function ( &$value ) use ( $preferredSynonyms ) {
863 $value = $preferredSynonyms[$value];
865 $legacyHooks = array_flip( $funcHooks );
868 $cmpHooks =
static function ( $a, $b ) {
869 return strcasecmp( ltrim( $a,
'#' ), ltrim( $b,
'#' ) );
871 usort( $funcHooks, $cmpHooks );
873 $formatHooks =
static function ( &$value ) {
875 $value = Html::rawElement(
881 array_walk( $funcHooks, $formatHooks );
883 $out .= Html::rawElement(
885 [
'id' =>
'mw-version-parser-function-hooks-list' ],
889 # Get a list of parser functions from Parsoid as well.
892 $siteConfig = $services->getParsoidSiteConfig();
893 $magicWordFactory = $services->getMagicWordFactory();
894 foreach ( $siteConfig->getPFragmentHandlerKeys() as $key ) {
895 $config = $siteConfig->getPFragmentHandlerConfig( $key );
896 if ( !( $config[
'options'][
'parserFunction'] ??
false ) ) {
899 $mw = $magicWordFactory->get( $key );
900 foreach ( $mw->getSynonyms() as $local ) {
901 if ( !( $config[
'options'][
'nohash'] ??
false ) ) {
902 $local =
'#' . $local;
906 if ( isset( $legacyHooks[$local] ) ) {
909 $parsoidHooks[] = $local;
912 if ( $parsoidHooks ) {
915 [
'id' =>
'mw-version-parser-function-hooks-parsoid' ],
916 $this->
msg(
'version-parser-function-hooks-parsoid' )->text()
918 usort( $parsoidHooks, $cmpHooks );
919 array_walk( $parsoidHooks, $formatHooks );
920 $out .= $this->
getLanguage()->listToText( $parsoidHooks );
933 $modules = $siteConfig->getExtensionModules();
939 $this->addTocSection(
id:
'mw-version-parsoid-modules',
msg:
'version-parsoid-modules' );
941 $out = Html::rawElement(
943 [
'id' =>
'mw-version-parsoid-modules' ],
946 [
'class' =>
'plainlinks' ],
948 'https://www.mediawiki.org/wiki/Special:MyLanguage/Parsoid',
949 $this->
msg(
'version-parsoid-modules' ),
955 $moduleNames = array_map(
957 'title' => $m->getConfig()[
'extension-name'] ??
null,
958 ], $m->getConfig()[
'name'] ),
962 $out .= Html::rawElement(
964 [
'id' =>
'mw-version-parsoid-modules-list' ],
983 if ( $creditsGroup ) {
984 $out .= $this->openExtType( $text,
'credits-' . $type );
986 usort( $creditsGroup, $this->compare( ... ) );
988 foreach ( $creditsGroup as $extension ) {
992 $out .= Html::closeElement(
'table' );
1004 private function compare( $a, $b ) {
1005 return $this->getLanguage()->lc( $a[
'name'] ) <=> $this->getLanguage()->lc( $b[
'name'] );
1031 if ( isset( $extension[
'namemsg'] ) ) {
1033 $extensionName = $this->
msg( $extension[
'namemsg'] )->text();
1034 } elseif ( isset( $extension[
'name'] ) ) {
1036 $extensionName = $extension[
'name'];
1038 $extensionName = $this->
msg(
'version-no-ext-name' )->text();
1041 if ( isset( $extension[
'url'] ) ) {
1047 [
'class' =>
'mw-version-ext-name' ]
1050 $extensionNameLink =
Html::element(
'span', [
'class' =>
'mw-version-ext-name' ], $extensionName );
1056 $canonicalVersion =
'–';
1057 $extensionPath =
null;
1062 if ( isset( $extension[
'version'] ) ) {
1063 $canonicalVersion = htmlspecialchars( $extension[
'version'] );
1066 if ( isset( $extension[
'path'] ) ) {
1067 $extensionPath = dirname( $extension[
'path'] );
1068 if ( $this->coreId ==
'' ) {
1069 wfDebug(
'Looking up core head id' );
1070 $coreHeadSHA1 = GitInfo::repo()->getHeadSHA1();
1071 if ( $coreHeadSHA1 ) {
1072 $this->coreId = $coreHeadSHA1;
1076 $memcKey = $cache->makeKey(
1077 'specialversion-ext-version-text', $extension[
'path'], $this->coreId
1079 $res = $cache->get( $memcKey );
1081 if ( $res ===
false ) {
1082 wfDebug(
"Getting VCS info for extension {$extension['name']}" );
1083 $gitInfo =
new GitInfo( $extensionPath );
1084 $vcsVersion = $gitInfo->getHeadSHA1();
1085 if ( $vcsVersion !==
false ) {
1086 $vcsVersion = substr( $vcsVersion, 0, 7 );
1087 $vcsLink = $gitInfo->getHeadViewUrl();
1088 $vcsDate = $gitInfo->getHeadCommitDate();
1090 $cache->set( $memcKey, [ $vcsVersion, $vcsLink, $vcsDate ], 60 * 60 * 24 );
1092 wfDebug(
"Pulled VCS info for extension {$extension['name']} from cache" );
1093 [ $vcsVersion, $vcsLink, $vcsDate ] = $res;
1097 $versionString = Html::rawElement(
1099 [
'class' =>
'mw-version-ext-version' ],
1103 if ( $vcsVersion ) {
1107 $this->
msg(
'version-version', $vcsVersion ),
1110 [
'class' =>
'mw-version-ext-vcs-version' ]
1114 [
'class' =>
'mw-version-ext-vcs-version' ],
1118 $versionString .=
" {$vcsVerString}";
1122 'class' =>
'mw-version-ext-vcs-timestamp',
1124 ], $this->
getLanguage()->timeanddate( $vcsDate,
true ) );
1126 $versionString = Html::rawElement(
'span',
1127 [
'class' =>
'mw-version-ext-meta-version' ],
1135 if ( isset( $extension[
'name'] ) ) {
1136 $licenseName =
null;
1137 if ( isset( $extension[
'license-name'] ) ) {
1138 $licenseName = $extension[
'license-name'];
1139 } elseif ( $extensionPath !==
null && ExtensionInfo::getLicenseFileNames( $extensionPath ) ) {
1140 $licenseName = $this->
msg(
'version-ext-license' )->text();
1142 if ( $licenseName !==
null ) {
1144 $this->
getPageTitle(
'License/' . $extension[
'name'] ),
1147 'class' =>
'mw-version-ext-license',
1157 if ( isset( $extension[
'descriptionmsg'] ) ) {
1159 $descriptionMsg = $extension[
'descriptionmsg'];
1161 if ( is_array( $descriptionMsg ) ) {
1162 $descriptionMsgKey = array_shift( $descriptionMsg );
1163 $descriptionMsg = array_map( htmlspecialchars( ... ), $descriptionMsg );
1164 $description = $this->
msg( $descriptionMsgKey, ...$descriptionMsg )->text();
1166 $description = $this->
msg( $descriptionMsg )->text();
1168 } elseif ( isset( $extension[
'description'] ) ) {
1170 $description = $extension[
'description'];
1174 $description = $out->parseInlineAsInterface( $description );
1177 $authors = $extension[
'author'] ?? [];
1179 $authors = $this->
listAuthors( $authors, $extension[
'name'], $extensionPath );
1182 $html = Html::openElement(
'tr', [
1183 'class' =>
'mw-version-ext',
1184 'id' => Sanitizer::escapeIdForAttribute(
'mw-version-ext-' . $type .
'-' . $extension[
'name'] )
1188 $html .= Html::rawElement(
'td', [], $extensionNameLink );
1189 $html .= Html::rawElement(
'td', [], $versionString );
1190 $html .= Html::rawElement(
'td', [], $licenseLink );
1191 $html .= Html::rawElement(
'td', [
'class' =>
'mw-version-ext-description' ], $description );
1192 $html .= Html::rawElement(
'td', [
'class' =>
'mw-version-ext-authors' ], $authors );
1194 $html .= Html::closeElement(
'tr' );
1204 private function getHooks() {
1210 $hookNames = $hookContainer->getHookNames();
1212 $hookNamesToHandlers = array_filter( array_combine(
1215 static fn ( $name ) => $hookContainer->getHandlerDescriptions( $name ),
1220 if ( !$hookNamesToHandlers ) {
1227 $this->addTocSection(
id:
'mw-version-hooks', msg:
'version-hooks' );
1228 $ret[] = Html::element(
1230 [
'id' =>
'mw-version-hooks' ],
1231 $this->msg(
'version-hooks' )->text()
1233 $ret[] = Html::openElement(
'table', [
'class' =>
'wikitable',
'id' =>
'sv-hooks' ] );
1234 $ret[] = Html::openElement(
'tr' );
1235 $ret[] = Html::element(
'th', [], $this->msg(
'version-hook-name' )->text() );
1236 $ret[] = Html::element(
'th', [], $this->msg(
'version-hook-subscribedby' )->text() );
1237 $ret[] = Html::closeElement(
'tr' );
1239 foreach ( $hookNamesToHandlers as $name => $handlers ) {
1240 $ret[] = Html::openElement(
'tr' );
1241 $ret[] = Html::element(
'td', [], $name );
1242 $ret[] = Html::element(
'td', [], $this->listToText( $handlers ) );
1243 $ret[] = Html::closeElement(
'tr' );
1246 $ret[] = Html::closeElement(
'table' );
1248 return implode(
"\n", $ret );
1251 private function openExtType( ?
string $text =
null, ?
string $name =
null ): string {
1254 $opt = [
'class' =>
'wikitable plainlinks mw-installed-software' ];
1257 $opt[
'id'] =
"sv-$name";
1260 $out .= Html::openElement(
'table', $opt );
1262 if ( $text !==
null ) {
1263 $out .= Html::element(
'caption', [], $text );
1266 if ( $name && $text !==
null ) {
1270 $firstHeadingMsg = ( $name ===
'credits-skin' )
1271 ?
'version-skin-colheader-name'
1272 :
'version-ext-colheader-name';
1274 $out .= $this->getTableHeaderHtml( [
1275 $this->
msg( $firstHeadingMsg )->text(),
1276 $this->
msg(
'version-ext-colheader-version' )->text(),
1277 $this->
msg(
'version-ext-colheader-license' )->text(),
1278 $this->
msg(
'version-ext-colheader-description' )->text(),
1279 $this->
msg(
'version-ext-colheader-credits' )->text()
1293 private function getTableHeaderHtml( $headers ): string {
1295 foreach ( $headers as $header ) {
1296 $out .= Html::element(
'th', [
'scope' =>
'col' ], $header );
1298 return Html::rawElement(
'thead', [],
1299 Html::rawElement(
'tr', [], $out )
1328 $authors = (array)$authors;
1333 if ( count( $authors ) === 1 && $authors[0] ===
'...' ) {
1336 if ( $extName && ExtensionInfo::getAuthorsFileName( $extDir ) ) {
1337 return $linkRenderer->makeLink(
1339 $this->
msg(
'version-poweredby-various' )->text()
1342 return $this->msg(
'version-poweredby-various' )->escaped();
1348 foreach ( $authors as $item ) {
1349 if ( $item instanceof HtmlArmor ) {
1350 $list[] = HtmlArmor::getHtml( $item );
1351 } elseif ( $item ===
'...' ) {
1354 if ( $extName && ExtensionInfo::getAuthorsFileName( $extDir ) ) {
1355 $text = $linkRenderer->makeLink(
1356 $this->getPageTitle(
"Credits/$extName" ),
1357 $this->
msg(
'version-poweredby-others' )->text()
1360 $text = $this->
msg(
'version-poweredby-others' )->escaped();
1363 } elseif ( str_ends_with( $item,
' ...]' ) ) {
1365 $list[] = $this->
getOutput()->parseInlineAsInterface(
1366 substr( $item, 0, -4 ) . $this->
msg(
'version-poweredby-others' )->text() .
"]"
1369 $list[] = $this->
getOutput()->parseInlineAsInterface( $item );
1373 if ( $extName && !$hasOthers && ExtensionInfo::getAuthorsFileName( $extDir ) ) {
1374 $list[] = $linkRenderer->makeLink(
1375 $this->getPageTitle(
"Credits/$extName" ),
1376 $this->
msg(
'version-poweredby-others' )->text()
1380 return $this->listToText( $list,
false );
1392 private function listToText( array $list,
bool $sort =
true ): string {
1401 ->listToText( array_map( self::arrayToString( ... ), $list ) );
1414 if ( is_array( $list ) && count( $list ) == 1 ) {
1417 if ( $list instanceof Closure ) {
1420 } elseif ( is_object( $list ) ) {
1421 return wfMessage(
'parentheses' )->params( get_class( $list ) )->escaped();
1422 } elseif ( !is_array( $list ) ) {
1425 if ( is_object( $list[0] ) ) {
1426 $class = get_class( $list[0] );
1431 return wfMessage(
'parentheses' )->params(
"$class, {$list[1]}" )->escaped();
1446 'version-entrypoints-index-php' =>
wfScript(
'index' ),
1447 'version-entrypoints-api-php' =>
wfScript(
'api' ),
1448 'version-entrypoints-rest-php' =>
wfScript(
'rest' ),
1453 'dir' => $language->getDir(),
1454 'lang' => $language->getHtmlCode(),
1458 $this->addTocSection(
id:
'mw-version-entrypoints',
msg:
'version-entrypoints' );
1462 [
'id' =>
'mw-version-entrypoints' ],
1463 $this->
msg(
'version-entrypoints' )->text()
1465 Html::openElement(
'table',
1467 'class' =>
'wikitable plainlinks',
1468 'id' =>
'mw-version-entrypoints-table',
1473 Html::openElement(
'thead' ) .
1474 Html::openElement(
'tr' ) .
1478 $this->
msg(
'version-entrypoints-header-entrypoint' )->text()
1483 $this->
msg(
'version-entrypoints-header-url' )->text()
1485 Html::closeElement(
'tr' ) .
1486 Html::closeElement(
'thead' );
1488 foreach ( $entryPoints as $message => $value ) {
1490 $out .= Html::openElement(
'tr' ) .
1491 Html::rawElement(
'td', [], $this->
msg( $message )->parse() ) .
1492 Html::rawElement(
'td', [],
1499 Html::closeElement(
'tr' );
1502 $out .= Html::closeElement(
'table' );
1521class_alias( SpecialVersion::class,
'SpecialVersion' );
const MW_VERSION
The running version of MediaWiki.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfScript( $script='index')
Get the URL path to a MediaWiki entry point.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
if(!defined('MW_SETUP_CALLBACK'))
A class containing constants representing the names of configuration variables.
const SpecialVersionShowHooks
Name constant for the SpecialVersionShowHooks setting, for use with Config\get().
const ArticlePath
Name constant for the ArticlePath setting, for use with Config\get().
const ScriptPath
Name constant for the ScriptPath setting, for use with Config\get().
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
getConfig()
Shortcut to get main config object.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getLanguage()
Shortcut to get user's language.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages By default the message key is the canonical name of...
getFullTitle()
Return the full title, including $par.