MediaWiki master
SpecialVersion.php
Go to the documentation of this file.
1<?php
8
9namespace MediaWiki\Specials;
10
11use Closure;
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;
33
40 use TocGeneratorTrait;
41
45 protected $coreId = '';
46
50 protected static $extensionTypes = false;
51
52 public function __construct(
53 private readonly ParserFactory $parserFactory,
54 private readonly UrlUtils $urlUtils,
55 private readonly IConnectionProvider $dbProvider
56 ) {
57 parent::__construct( 'Version' );
58 }
59
67 public static function getCredits( ExtensionRegistry $reg, Config $conf ): array {
68 $credits = $conf->get( MainConfigNames::ExtensionCredits );
69 foreach ( $reg->getAllThings() as $credit ) {
70 $credits[$credit['type']][] = $credit;
71 }
72 return $credits;
73 }
74
78 public function execute( $par ) {
79 $config = $this->getConfig();
80 $credits = self::getCredits( MediaWikiServices::getInstance()->getExtensionRegistry(), $config );
81
82 $this->setHeaders();
83 $this->outputHeader();
84 $out = $this->getOutput();
85 $out->getMetadata()->setPreventClickjacking( false );
86
87 // Explode the subpage information into useful bits
88 $parts = explode( '/', (string)$par );
89 $extNode = null;
90 if ( isset( $parts[1] ) ) {
91 $extName = str_replace( '_', ' ', $parts[1] );
92 // Find it!
93 foreach ( $credits as $extensions ) {
94 foreach ( $extensions as $ext ) {
95 if ( isset( $ext['name'] ) && ( $ext['name'] === $extName ) ) {
96 $extNode = &$ext;
97 break 2;
98 }
99 }
100 }
101 if ( !$extNode ) {
102 $out->setStatusCode( 404 );
103 }
104 } else {
105 $extName = 'MediaWiki';
106 }
107
108 // The subpage names software that isn't installed
109 $extNotFound = $extNode === null && $extName !== 'MediaWiki';
110
111 // Now figure out what to do
112 switch ( strtolower( $parts[0] ) ) {
113 case 'credits':
114 $out->addModuleStyles( 'mediawiki.special' );
115
116 $wikiText = '{{int:version-credits-not-found}}';
117 if ( $extName === 'MediaWiki' ) {
118 $wikiText = file_get_contents( MW_INSTALL_PATH . '/CREDITS' );
119 // Put the contributor list into columns
120 $wikiText = str_replace(
121 [ '<!-- BEGIN CONTRIBUTOR LIST -->', '<!-- END CONTRIBUTOR LIST -->' ],
122 [ '<div class="mw-version-credits">', '</div>' ],
123 $wikiText
124 );
125 } elseif ( ( $extNode !== null ) && isset( $extNode['path'] ) ) {
126 $file = ExtensionInfo::getAuthorsFileName( dirname( $extNode['path'] ) );
127 if ( $file ) {
128 $wikiText = file_get_contents( $file );
129 if ( str_ends_with( $file, '.txt' ) ) {
130 $wikiText = Html::element(
131 'pre',
132 [
133 'lang' => 'en',
134 'dir' => 'ltr',
135 ],
136 $wikiText
137 );
138 }
139 }
140 }
141
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() );
145 } else {
146 $out->addWikiTextAsInterface( $wikiText );
147 }
148 break;
149
150 case 'license':
151 $out->setPageTitleMsg( $this->msg( 'version-license-title' )->plaintextParams( $extName ) );
152
153 $licenseFound = false;
154
155 if ( $extName === 'MediaWiki' ) {
156 $license = file_get_contents( MW_INSTALL_PATH . '/COPYING' );
157 $license = str_replace(
158 'CREDITS file',
159 '[[Special:Version/Credits|CREDITS file]]',
160 $license
161 );
162 $out->addWikiTextAsInterface( $license );
163 $licenseFound = true;
164 } elseif ( ( $extNode !== null ) && isset( $extNode['path'] ) ) {
165 $files = ExtensionInfo::getLicenseFileNames( dirname( $extNode['path'] ) );
166 if ( $files ) {
167 $licenseFound = true;
168 foreach ( $files as $file ) {
169 $out->addWikiTextAsInterface(
171 'pre',
172 [
173 'lang' => 'en',
174 'dir' => 'ltr',
175 ],
176 file_get_contents( $file )
177 )
178 );
179 }
180 }
181 }
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}}' );
186 }
187 break;
188
189 default:
190 $out->addModuleStyles( 'mediawiki.special' );
191
192 // The API only serves the SBOM to named users
193 if ( $this->getUser()->isNamed() ) {
194 $out->addModuleStyles( 'mediawiki.htmlform.codex.styles' );
195 $out->addModules( 'mediawiki.misc-authed-ooui' );
196 $out->setIndicators( [ 'mw-version-sbom' => Html::element(
197 'a',
198 [
199 'id' => 'mw-version-sbom-download',
200 'class' => 'cdx-button cdx-button--fake-button cdx-button--fake-button--enabled',
201 'href' => $this->getConfig()->get( MainConfigNames::ScriptPath ) . '/api.php?' .
202 http_build_query( [
203 'action' => 'query',
204 'meta' => 'siteinfo',
205 'siprop' => 'sbom',
206 'format' => 'json',
207 'formatversion' => '2',
208 ] ),
209 'download' => 'sbom.cdx.json',
210 ],
211 $this->msg( 'version-download-sbom' )->text()
212 ) ] );
213 }
214
215 $out->addHTML( $this->getMediaWikiCredits() );
216
217 // Build the page contents (this also fills in TOCData)
218 $sections = [
219 $this->softwareInformation(),
220 $this->getEntryPointInfo(),
221 $this->getSkinCredits( $credits ),
222 $this->getExtensionCredits( $credits ),
223 $this->getLibraries( $credits ),
224 $this->getParserTags(),
225 $this->getParserFunctionHooks(),
226 $this->getParsoidModules(),
227 $this->getHooks(),
228 ];
229
230 // Insert TOC first
231 $out->addTOCPlaceholder( $this->getTocData() );
232
233 // Insert contents
234 foreach ( $sections as $content ) {
235 $out->addHTML( $content );
236 }
237
238 break;
239 }
240 }
241
247 private function getMediaWikiCredits() {
248 // No TOC entry for this heading, we treat it like the lede section
249
250 $ret = Html::element(
251 'h2',
252 [ 'id' => 'mw-version-license' ],
253 $this->msg( 'version-license' )->text()
254 );
255
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()
260 )
261 );
262
263 return $ret;
264 }
265
272 public static function getCopyrightAndAuthorList() {
273 if ( defined( 'MEDIAWIKI_INSTALL' ) ) {
274 $othersLink = '[https://www.mediawiki.org/wiki/Special:Version/Credits ' .
275 wfMessage( 'version-poweredby-others' )->plain() . ']';
276 } else {
277 $othersLink = '[[Special:Version/Credits|' .
278 wfMessage( 'version-poweredby-others' )->plain() . ']]';
279 }
280
281 $translatorsLink = '[https://translatewiki.net/wiki/Translating:MediaWiki/Credits ' .
282 wfMessage( 'version-poweredby-translators' )->plain() . ']';
283
284 $authorList = [
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
300 ];
301
302 return Html::rawElement(
303 'div',
304 [ 'id' => 'mw-version-poweredby-credits' ],
305 wfMessage(
306 'version-poweredby-credits',
307 MWTimestamp::getLocalInstance()->format( 'Y' ),
308 Message::listParam( $authorList )
309 )->plain()
310 );
311 }
312
318 private function getSoftwareInformation() {
319 $dbr = $this->dbProvider->getReplicaDatabase();
320
321 // Put the software in an array of form 'name' => 'version'. All messages should
322 // be loaded here, so feel free to use wfMessage in the 'name'. Wikitext
323 // can be used both in the name and value.
324 $versionLink = $this->getVersionLinkedGit() ?: MW_VERSION;
325 $software = [
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(),
330 ];
331
332 // T339915: If wikidiff2 is installed, show version
333 if ( phpversion( "wikidiff2" ) ) {
334 $software[ '[https://www.mediawiki.org/wiki/Wikidiff2 wikidiff2]' ] = phpversion( "wikidiff2" );
335 }
336
337 // Allow a hook to add/remove items.
338 $this->getHookRunner()->onSoftwareInfo( $software );
339
340 return $software;
341 }
342
348 private function softwareInformation() {
349 $this->addTocSection( id: 'mw-version-software', msg: 'version-software' );
350
351 $out = Html::element(
352 'h2',
353 [ 'id' => 'mw-version-software' ],
354 $this->msg( 'version-software' )->text()
355 );
356
357 $out .= Html::openElement( 'table', [ 'class' => 'wikitable plainlinks', 'id' => 'sv-software' ] );
358
359 $out .= $this->getTableHeaderHtml( [
360 $this->msg( 'version-software-product' )->text(),
361 $this->msg( 'version-software-version' )->text()
362 ] );
363
364 foreach ( $this->getSoftwareInformation() as $name => $version ) {
365 $out .= Html::rawElement(
366 'tr',
367 [],
368 Html::rawElement( 'td', [], $this->msg( new RawMessage( $name ) )->parse() ) .
369 Html::rawElement( 'td', [ 'dir' => 'ltr' ], $this->msg( new RawMessage( $version ) )->parse() )
370 );
371 }
372
373 $out .= Html::closeElement( 'table' );
374
375 return $out;
376 }
377
387 public static function getVersion( $flags = '', $lang = null ) {
388 $gitInfo = GitInfo::repo()->getHeadSHA1();
389 if ( !$gitInfo ) {
390 $version = MW_VERSION;
391 } elseif ( $flags === 'nodb' ) {
392 $shortSha1 = substr( $gitInfo, 0, 7 );
393 $version = MW_VERSION . " ($shortSha1)";
394 } else {
395 $shortSha1 = substr( $gitInfo, 0, 7 );
396 $msg = wfMessage( 'parentheses' );
397 if ( $lang !== null ) {
398 $msg->inLanguage( $lang );
399 }
400 $shortSha1 = $msg->params( $shortSha1 )->text();
401 $version = MW_VERSION . ' ' . $shortSha1;
402 }
403
404 return $version;
405 }
406
407 private function getMWVersionLinked(): string {
408 $versionUrl = "";
409 if ( $this->getHookRunner()->onSpecialVersionVersionUrl( MW_VERSION, $versionUrl ) ) {
410 $versionParts = [];
411 preg_match( "/^(\d+\.\d+)/", MW_VERSION, $versionParts );
412 $versionUrl = "https://www.mediawiki.org/wiki/MediaWiki_{$versionParts[1]}";
413 }
414
415 return '[' . $versionUrl . ' ' . MW_VERSION . ']';
416 }
417
423 private function getVersionLinkedGit(): bool|string {
424 $gitInfo = new GitInfo( MW_INSTALL_PATH );
425 $headSHA1 = $gitInfo->getHeadSHA1();
426 if ( !$headSHA1 ) {
427 return false;
428 }
429
430 $shortSHA1 = '(' . substr( $headSHA1, 0, 7 ) . ')';
431
432 $gitHeadUrl = $gitInfo->getHeadViewUrl();
433 if ( $gitHeadUrl !== false ) {
434 $shortSHA1 = "[$gitHeadUrl $shortSHA1]";
435 }
436
437 $gitHeadCommitDate = $gitInfo->getHeadCommitDate();
438 if ( $gitHeadCommitDate ) {
439 $shortSHA1 .= Html::element( 'br' );
440 $shortSHA1 .= $this->getLanguage()->timeanddate( (string)$gitHeadCommitDate, true );
441 }
442
443 return $this->getMWVersionLinked() . " $shortSHA1";
444 }
445
455 public static function getExtensionTypes(): array {
456 if ( self::$extensionTypes === false ) {
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(),
468 ];
469
471 ->onExtensionTypes( self::$extensionTypes );
472 }
473
474 return self::$extensionTypes;
475 }
476
483 private function getExtensionCredits( array $credits ) {
484 $extensionTypes = self::getExtensionTypes();
485
486 $this->addTocSection( id: 'mw-version-ext', msg: 'version-extensions' );
487
488 $out = Html::element(
489 'h2',
490 [ 'id' => 'mw-version-ext' ],
491 $this->msg( 'version-extensions' )->text()
492 );
493
494 if (
495 !$credits ||
496 // Skins are displayed separately, see getSkinCredits()
497 ( count( $credits ) === 1 && isset( $credits['skin'] ) )
498 ) {
499 $out .= Html::element(
500 'p',
501 [],
502 $this->msg( 'version-extensions-no-ext' )->text()
503 );
504
505 return $out;
506 }
507
508 // Find all extensions that do not have a valid type and give them the type 'other'.
509 $credits['other'] ??= [];
510 foreach ( $credits as $type => $extensions ) {
511 if ( !array_key_exists( $type, $extensionTypes ) ) {
512 $credits['other'] = array_merge( $credits['other'], $extensions );
513 }
514 }
515
516 // Loop through the extension categories to display their extensions in the list.
517 foreach ( $extensionTypes as $type => $text ) {
518 // Skins have a separate section
519 if ( $type !== 'other' && $type !== 'skin' ) {
520 $out .= $this->getExtensionCategory( $type, $text, $credits[$type] ?? [] );
521 }
522 }
523
524 // We want the 'other' type to be last in the list.
525 $out .= $this->getExtensionCategory( 'other', $extensionTypes['other'], $credits['other'] );
526
527 return $out;
528 }
529
536 private function getSkinCredits( array $credits ) {
537 $this->addTocSection( id: 'mw-version-skin', msg: 'version-skins' );
538
539 $out = Html::element(
540 'h2',
541 [ 'id' => 'mw-version-skin' ],
542 $this->msg( 'version-skins' )->text()
543 );
544
545 if ( !isset( $credits['skin'] ) || !$credits['skin'] ) {
546 $out .= Html::element(
547 'p',
548 [],
549 $this->msg( 'version-skins-no-skin' )->text()
550 );
551
552 return $out;
553 }
554 $out .= $this->getExtensionCategory( 'skin', null, $credits['skin'] );
555
556 return $out;
557 }
558
565 protected function getLibraries( array $credits ) {
566 $this->addTocSection( id: 'mw-version-libraries', msg: 'version-libraries' );
567
568 $out = Html::element(
569 'h2',
570 [ 'id' => 'mw-version-libraries' ],
571 $this->msg( 'version-libraries' )->text()
572 );
573
574 return $out
575 . $this->getExternalLibraries( $credits )
576 . $this->getClientSideLibraries();
577 }
578
585 public static function parseComposerInstalled( array $credits ) {
586 $paths = [
587 MW_INSTALL_PATH . '/vendor/composer/installed.json'
588 ];
589
590 $extensionTypes = self::getExtensionTypes();
591 foreach ( $extensionTypes as $type => $message ) {
592 if ( !isset( $credits[$type] ) || $credits[$type] === [] ) {
593 continue;
594 }
595 foreach ( $credits[$type] as $extension ) {
596 if ( !isset( $extension['path'] ) ) {
597 continue;
598 }
599 $paths[] = dirname( $extension['path'] ) . '/vendor/composer/installed.json';
600 }
601 }
602
603 $dependencies = [];
604
605 foreach ( $paths as $path ) {
606 if ( !file_exists( $path ) ) {
607 continue;
608 }
609
610 $installed = new ComposerInstalled( $path );
611
612 $dependencies += $installed->getInstalledDependencies();
613 }
614
615 ksort( $dependencies );
616 return $dependencies;
617 }
618
625 protected function getExternalLibraries( array $credits ) {
626 $dependencies = self::parseComposerInstalled( $credits );
627 if ( $dependencies === [] ) {
628 return '';
629 }
630
631 $this->addTocSubSection( id: 'mw-version-libraries-server', msg: 'version-libraries-server' );
632
633 $out = Html::element(
634 'h3',
635 [ 'id' => 'mw-version-libraries-server' ],
636 $this->msg( 'version-libraries-server' )->text()
637 );
638 $out .= Html::openElement(
639 'table',
640 [ 'class' => 'wikitable plainlinks mw-installed-software', 'id' => 'sv-libraries' ]
641 );
642
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(),
649 ] );
650
651 foreach ( $dependencies as $name => $info ) {
652 if ( !is_array( $info ) || str_starts_with( $info['type'], 'mediawiki-' ) ) {
653 // Skip any extensions or skins since they'll be listed
654 // in their proper section
655 continue;
656 }
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'] )
661 );
662 }, $info['authors'] );
663 $authors = $this->listAuthors( $authors, false, MW_INSTALL_PATH . "/vendor/$name" );
664
665 // We can safely assume that the libraries' names and descriptions
666 // are written in English and aren't going to be translated,
667 // so set appropriate lang and dir attributes
668 $out .= Html::openElement( 'tr', [
669 // Add an anchor so docs can link easily to the version of
670 // this specific library
671 'id' => Sanitizer::escapeIdForAttribute(
672 "mw-version-library-$name"
673 ) ] )
674 . Html::rawElement(
675 'td',
676 [],
677 $this->getLinkRenderer()->makeExternalLink(
678 "https://packagist.org/packages/$name",
679 $name,
680 $this->getFullTitle(),
681 '',
682 [ 'class' => 'mw-version-library-name' ]
683 )
684 )
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' );
690 }
691 $out .= Html::closeElement( 'table' );
692
693 return $out;
694 }
695
701 public static function parseForeignResources() {
702 $registryDirs = [ 'MediaWiki' => MW_INSTALL_PATH . '/resources/lib' ]
703 + ExtensionRegistry::getInstance()->getAttribute( 'ForeignResourcesDir' );
704
705 $modules = [];
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;
712 continue;
713 }
714 $modules[$key] = $module + [ 'name' => $name, 'source' => [ $source ] ];
715 }
716 }
717 ksort( $modules );
718 return $modules;
719 }
720
726 private function getClientSideLibraries() {
727 $this->addTocSubSection( id: 'mw-version-libraries-client', msg: 'version-libraries-client' );
728
729 $out = Html::element(
730 'h3',
731 [ 'id' => 'mw-version-libraries-client' ],
732 $this->msg( 'version-libraries-client' )->text()
733 );
734 $out .= Html::openElement(
735 'table',
736 [ 'class' => 'wikitable plainlinks mw-installed-software', 'id' => 'sv-libraries-client' ]
737 );
738
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()
745 ] );
746
747 foreach ( self::parseForeignResources() as $name => $info ) {
748 // We can safely assume that the libraries' names and descriptions
749 // are written in English and aren't going to be translated,
750 // so set appropriate lang and dir attributes
751 $out .= Html::openElement( 'tr', [
752 // Add an anchor so docs can link easily to the version of
753 // this specific library
754 'id' => Sanitizer::escapeIdForAttribute(
755 "mw-version-library-$name"
756 ) ] )
757 . Html::rawElement(
758 'td',
759 [],
760 $this->getLinkRenderer()->makeExternalLink(
761 $info['homepage'],
762 $info['name'],
763 $this->getFullTitle(),
764 '',
765 [ 'class' => 'mw-version-library-name' ]
766 )
767 )
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' );
773 }
774 $out .= Html::closeElement( 'table' );
775
776 return $out;
777 }
778
784 protected function getParserTags() {
785 $tags = $this->parserFactory->getMainInstance()->getTags();
786 if ( !$tags ) {
787 return '';
788 }
789
790 $this->addTocSection( id: 'mw-version-parser-extensiontags', msg: 'version-parser-extensiontags' );
791
792 $out = Html::rawElement(
793 'h2',
794 [ 'id' => 'mw-version-parser-extensiontags' ],
795 Html::rawElement(
796 'span',
797 [ 'class' => 'plainlinks' ],
798 $this->getLinkRenderer()->makeExternalLink(
799 'https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Tag_extensions',
800 $this->msg( 'version-parser-extensiontags' ),
801 $this->getFullTitle()
802 )
803 )
804 );
805
806 array_walk( $tags, static function ( &$value ) {
807 // Bidirectional isolation improves readability in RTL wikis
808 $value = Html::rawElement(
809 'bdi',
810 // Prevent < and > from slipping to another line
811 [
812 'style' => 'white-space: nowrap;',
813 ],
814 Html::element( 'code', [], "<$value>" )
815 );
816 } );
817
818 $out .= Html::rawElement(
819 'div',
820 [ 'id' => 'mw-version-parser-extensiontags-list' ],
821 $this->listToText( $tags )
822 );
823
824 return $out;
825 }
826
832 protected function getParserFunctionHooks() {
833 $funcHooks = $this->parserFactory->getMainInstance()->getFunctionHooks();
834 if ( !$funcHooks ) {
835 return '';
836 }
837
838 $this->addTocSection( id: 'mw-version-parser-function-hooks', msg: 'version-parser-function-hooks' );
839
840 $out = Html::rawElement(
841 'h2',
842 [ 'id' => 'mw-version-parser-function-hooks' ],
843 Html::rawElement(
844 'span',
845 [ 'class' => 'plainlinks' ],
846 $this->getLinkRenderer()->makeExternalLink(
847 'https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Parser_functions',
848 $this->msg( 'version-parser-function-hooks' ),
849 $this->getFullTitle()
850 )
851 )
852 );
853
854 $funcSynonyms = $this->parserFactory->getMainInstance()->getFunctionSynonyms();
855 // This will give us the preferred synonyms in the content language, as if
856 // we used MagicWord::getSynonym( 0 ), because they appear first in the arrays.
857 // We can't use MagicWord directly, because only Parser knows whether a function
858 // uses the leading "#" or not. Case-sensitive functions ("1") win over
859 // case-insensitive ones ("0"), like in Parser::callParserFunction().
860 // There should probably be a better API for this.
861 $preferredSynonyms = array_flip( array_reverse( $funcSynonyms[1] + $funcSynonyms[0] ) );
862 array_walk( $funcHooks, static function ( &$value ) use ( $preferredSynonyms ) {
863 $value = $preferredSynonyms[$value];
864 } );
865 $legacyHooks = array_flip( $funcHooks );
866
867 // Sort case-insensitively, ignoring the leading '#' if present
868 $cmpHooks = static function ( $a, $b ) {
869 return strcasecmp( ltrim( $a, '#' ), ltrim( $b, '#' ) );
870 };
871 usort( $funcHooks, $cmpHooks );
872
873 $formatHooks = static function ( &$value ) {
874 // Bidirectional isolation ensures it displays as {{#ns}} and not {{ns#}} in RTL wikis
875 $value = Html::rawElement(
876 'bdi',
877 [],
878 Html::element( 'code', [], '{{' . $value . '}}' )
879 );
880 };
881 array_walk( $funcHooks, $formatHooks );
882
883 $out .= Html::rawElement(
884 'div',
885 [ 'id' => 'mw-version-parser-function-hooks-list' ],
886 $this->getLanguage()->listToText( $funcHooks )
887 );
888
889 # Get a list of parser functions from Parsoid as well.
890 $parsoidHooks = [];
891 $services = MediaWikiServices::getInstance();
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 ) ) {
897 continue;
898 }
899 $mw = $magicWordFactory->get( $key );
900 foreach ( $mw->getSynonyms() as $local ) {
901 if ( !( $config['options']['nohash'] ?? false ) ) {
902 $local = '#' . $local;
903 }
904 // Skip hooks already present in legacy hooks (they will
905 // also work in parsoid)
906 if ( isset( $legacyHooks[$local] ) ) {
907 continue;
908 }
909 $parsoidHooks[] = $local;
910 }
911 }
912 if ( $parsoidHooks ) {
913 $out .= Html::element(
914 'h3',
915 [ 'id' => 'mw-version-parser-function-hooks-parsoid' ],
916 $this->msg( 'version-parser-function-hooks-parsoid' )->text()
917 );
918 usort( $parsoidHooks, $cmpHooks );
919 array_walk( $parsoidHooks, $formatHooks );
920 $out .= $this->getLanguage()->listToText( $parsoidHooks );
921 }
922
923 return $out;
924 }
925
931 protected function getParsoidModules() {
932 $siteConfig = MediaWikiServices::getInstance()->getParsoidSiteConfig();
933 $modules = $siteConfig->getExtensionModules();
934
935 if ( !$modules ) {
936 return '';
937 }
938
939 $this->addTocSection( id: 'mw-version-parsoid-modules', msg: 'version-parsoid-modules' );
940
941 $out = Html::rawElement(
942 'h2',
943 [ 'id' => 'mw-version-parsoid-modules' ],
944 Html::rawElement(
945 'span',
946 [ 'class' => 'plainlinks' ],
947 $this->getLinkRenderer()->makeExternalLink(
948 'https://www.mediawiki.org/wiki/Special:MyLanguage/Parsoid',
949 $this->msg( 'version-parsoid-modules' ),
950 $this->getFullTitle()
951 )
952 )
953 );
954
955 $moduleNames = array_map(
956 static fn ( $m )=>Html::element( 'code', [
957 'title' => $m->getConfig()['extension-name'] ?? null,
958 ], $m->getConfig()['name'] ),
959 $modules
960 );
961
962 $out .= Html::rawElement(
963 'div',
964 [ 'id' => 'mw-version-parsoid-modules-list' ],
965 $this->getLanguage()->listToText( $moduleNames )
966 );
967
968 return $out;
969 }
970
980 protected function getExtensionCategory( $type, ?string $text, array $creditsGroup ) {
981 $out = '';
982
983 if ( $creditsGroup ) {
984 $out .= $this->openExtType( $text, 'credits-' . $type );
985
986 usort( $creditsGroup, $this->compare( ... ) );
987
988 foreach ( $creditsGroup as $extension ) {
989 $out .= $this->getCreditsForExtension( $type, $extension );
990 }
991
992 $out .= Html::closeElement( 'table' );
993 }
994
995 return $out;
996 }
997
1004 private function compare( $a, $b ) {
1005 return $this->getLanguage()->lc( $a['name'] ) <=> $this->getLanguage()->lc( $b['name'] );
1006 }
1007
1026 public function getCreditsForExtension( $type, array $extension ) {
1027 $out = $this->getOutput();
1028
1029 // We must obtain the information for all the bits and pieces!
1030 // ... such as extension names and links
1031 if ( isset( $extension['namemsg'] ) ) {
1032 // Localized name of extension
1033 $extensionName = $this->msg( $extension['namemsg'] )->text();
1034 } elseif ( isset( $extension['name'] ) ) {
1035 // Non localized version
1036 $extensionName = $extension['name'];
1037 } else {
1038 $extensionName = $this->msg( 'version-no-ext-name' )->text();
1039 }
1040
1041 if ( isset( $extension['url'] ) ) {
1042 $extensionNameLink = $this->getLinkRenderer()->makeExternalLink(
1043 $extension['url'],
1044 $extensionName,
1045 $this->getFullTitle(),
1046 '',
1047 [ 'class' => 'mw-version-ext-name' ]
1048 );
1049 } else {
1050 $extensionNameLink = Html::element( 'span', [ 'class' => 'mw-version-ext-name' ], $extensionName );
1051 }
1052
1053 // ... and the version information
1054 // If the extension path is set we will check that directory for GIT
1055 // metadata in an attempt to extract date and vcs commit metadata.
1056 $canonicalVersion = '&ndash;';
1057 $extensionPath = null;
1058 $vcsVersion = null;
1059 $vcsLink = null;
1060 $vcsDate = null;
1061
1062 if ( isset( $extension['version'] ) ) {
1063 $canonicalVersion = htmlspecialchars( $extension['version'] );
1064 }
1065
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;
1073 }
1074 }
1075 $cache = MediaWikiServices::getInstance()->getObjectCacheFactory()->getInstance( CACHE_ANYTHING );
1076 $memcKey = $cache->makeKey(
1077 'specialversion-ext-version-text', $extension['path'], $this->coreId
1078 );
1079 $res = $cache->get( $memcKey );
1080
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();
1089 }
1090 $cache->set( $memcKey, [ $vcsVersion, $vcsLink, $vcsDate ], 60 * 60 * 24 );
1091 } else {
1092 wfDebug( "Pulled VCS info for extension {$extension['name']} from cache" );
1093 [ $vcsVersion, $vcsLink, $vcsDate ] = $res;
1094 }
1095 }
1096
1097 $versionString = Html::rawElement(
1098 'span',
1099 [ 'class' => 'mw-version-ext-version' ],
1100 $canonicalVersion
1101 );
1102
1103 if ( $vcsVersion ) {
1104 if ( $vcsLink ) {
1105 $vcsVerString = $this->getLinkRenderer()->makeExternalLink(
1106 $vcsLink,
1107 $this->msg( 'version-version', $vcsVersion ),
1108 $this->getFullTitle(),
1109 '',
1110 [ 'class' => 'mw-version-ext-vcs-version' ]
1111 );
1112 } else {
1113 $vcsVerString = Html::element( 'span',
1114 [ 'class' => 'mw-version-ext-vcs-version' ],
1115 "({$vcsVersion})"
1116 );
1117 }
1118 $versionString .= " {$vcsVerString}";
1119
1120 if ( $vcsDate ) {
1121 $versionString .= ' ' . Html::element( 'span', [
1122 'class' => 'mw-version-ext-vcs-timestamp',
1123 'dir' => $this->getLanguage()->getDir(),
1124 ], $this->getLanguage()->timeanddate( $vcsDate, true ) );
1125 }
1126 $versionString = Html::rawElement( 'span',
1127 [ 'class' => 'mw-version-ext-meta-version' ],
1128 $versionString
1129 );
1130 }
1131
1132 // ... and license information; if a license file exists we
1133 // will link to it
1134 $licenseLink = '';
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();
1141 }
1142 if ( $licenseName !== null ) {
1143 $licenseLink = $this->getLinkRenderer()->makeLink(
1144 $this->getPageTitle( 'License/' . $extension['name'] ),
1145 $licenseName,
1146 [
1147 'class' => 'mw-version-ext-license',
1148 'dir' => 'auto',
1149 ]
1150 );
1151 }
1152 }
1153
1154 // ... and generate the description; which can be a parameterized l10n message
1155 // in the form [ <msgname>, <parameter>, <parameter>... ] or just a straight
1156 // up string
1157 if ( isset( $extension['descriptionmsg'] ) ) {
1158 // Localized description of extension
1159 $descriptionMsg = $extension['descriptionmsg'];
1160
1161 if ( is_array( $descriptionMsg ) ) {
1162 $descriptionMsgKey = array_shift( $descriptionMsg );
1163 $descriptionMsg = array_map( htmlspecialchars( ... ), $descriptionMsg );
1164 $description = $this->msg( $descriptionMsgKey, ...$descriptionMsg )->text();
1165 } else {
1166 $description = $this->msg( $descriptionMsg )->text();
1167 }
1168 } elseif ( isset( $extension['description'] ) ) {
1169 // Non localized version
1170 $description = $extension['description'];
1171 } else {
1172 $description = '';
1173 }
1174 $description = $out->parseInlineAsInterface( $description );
1175
1176 // ... now get the authors for this extension
1177 $authors = $extension['author'] ?? [];
1178 // @phan-suppress-next-line PhanTypeMismatchArgumentNullable path is set when there is a name
1179 $authors = $this->listAuthors( $authors, $extension['name'], $extensionPath );
1180
1181 // Finally! Create the table
1182 $html = Html::openElement( 'tr', [
1183 'class' => 'mw-version-ext',
1184 'id' => Sanitizer::escapeIdForAttribute( 'mw-version-ext-' . $type . '-' . $extension['name'] )
1185 ]
1186 );
1187
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 );
1193
1194 $html .= Html::closeElement( 'tr' );
1195
1196 return $html;
1197 }
1198
1204 private function getHooks() {
1205 if ( !$this->getConfig()->get( MainConfigNames::SpecialVersionShowHooks ) ) {
1206 return '';
1207 }
1208
1209 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
1210 $hookNames = $hookContainer->getHookNames();
1211
1212 $hookNamesToHandlers = array_filter( array_combine(
1213 $hookNames,
1214 array_map(
1215 static fn ( $name ) => $hookContainer->getHandlerDescriptions( $name ),
1216 $hookNames
1217 )
1218 ) );
1219
1220 if ( !$hookNamesToHandlers ) {
1221 return '';
1222 }
1223
1224 sort( $hookNames );
1225
1226 $ret = [];
1227 $this->addTocSection( id: 'mw-version-hooks', msg: 'version-hooks' );
1228 $ret[] = Html::element(
1229 'h2',
1230 [ 'id' => 'mw-version-hooks' ],
1231 $this->msg( 'version-hooks' )->text()
1232 );
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' );
1238
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' );
1244 }
1245
1246 $ret[] = Html::closeElement( 'table' );
1247
1248 return implode( "\n", $ret );
1249 }
1250
1251 private function openExtType( ?string $text = null, ?string $name = null ): string {
1252 $out = '';
1253
1254 $opt = [ 'class' => 'wikitable plainlinks mw-installed-software' ];
1255
1256 if ( $name ) {
1257 $opt['id'] = "sv-$name";
1258 }
1259
1260 $out .= Html::openElement( 'table', $opt );
1261
1262 if ( $text !== null ) {
1263 $out .= Html::element( 'caption', [], $text );
1264 }
1265
1266 if ( $name && $text !== null ) {
1267 $this->addTocSubSection( "sv-$name", 'rawmessage', $text );
1268 }
1269
1270 $firstHeadingMsg = ( $name === 'credits-skin' )
1271 ? 'version-skin-colheader-name'
1272 : 'version-ext-colheader-name';
1273
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()
1280 ] );
1281
1282 return $out;
1283 }
1284
1293 private function getTableHeaderHtml( $headers ): string {
1294 $out = '';
1295 foreach ( $headers as $header ) {
1296 $out .= Html::element( 'th', [ 'scope' => 'col' ], $header );
1297 }
1298 return Html::rawElement( 'thead', [],
1299 Html::rawElement( 'tr', [], $out )
1300 );
1301 }
1302
1323 public function listAuthors( $authors, $extName, $extDir ): string {
1324 $hasOthers = false;
1325 $linkRenderer = $this->getLinkRenderer();
1326
1327 $list = [];
1328 $authors = (array)$authors;
1329
1330 // Special case: if the authors array has only one item and it is "...",
1331 // it should not be rendered as the "version-poweredby-others" i18n msg,
1332 // but rather as "version-poweredby-various" i18n msg instead.
1333 if ( count( $authors ) === 1 && $authors[0] === '...' ) {
1334 // Link to the extension's or skin's AUTHORS or CREDITS file, if there is
1335 // such a file; otherwise just return the i18n msg as-is
1336 if ( $extName && ExtensionInfo::getAuthorsFileName( $extDir ) ) {
1337 return $linkRenderer->makeLink(
1338 $this->getPageTitle( "Credits/$extName" ),
1339 $this->msg( 'version-poweredby-various' )->text()
1340 );
1341 } else {
1342 return $this->msg( 'version-poweredby-various' )->escaped();
1343 }
1344 }
1345
1346 // Otherwise, if we have an actual array that has more than one item,
1347 // process each array item as usual
1348 foreach ( $authors as $item ) {
1349 if ( $item instanceof HtmlArmor ) {
1350 $list[] = HtmlArmor::getHtml( $item );
1351 } elseif ( $item === '...' ) {
1352 $hasOthers = true;
1353
1354 if ( $extName && ExtensionInfo::getAuthorsFileName( $extDir ) ) {
1355 $text = $linkRenderer->makeLink(
1356 $this->getPageTitle( "Credits/$extName" ),
1357 $this->msg( 'version-poweredby-others' )->text()
1358 );
1359 } else {
1360 $text = $this->msg( 'version-poweredby-others' )->escaped();
1361 }
1362 $list[] = $text;
1363 } elseif ( str_ends_with( $item, ' ...]' ) ) {
1364 $hasOthers = true;
1365 $list[] = $this->getOutput()->parseInlineAsInterface(
1366 substr( $item, 0, -4 ) . $this->msg( 'version-poweredby-others' )->text() . "]"
1367 );
1368 } else {
1369 $list[] = $this->getOutput()->parseInlineAsInterface( $item );
1370 }
1371 }
1372
1373 if ( $extName && !$hasOthers && ExtensionInfo::getAuthorsFileName( $extDir ) ) {
1374 $list[] = $linkRenderer->makeLink(
1375 $this->getPageTitle( "Credits/$extName" ),
1376 $this->msg( 'version-poweredby-others' )->text()
1377 );
1378 }
1379
1380 return $this->listToText( $list, false );
1381 }
1382
1392 private function listToText( array $list, bool $sort = true ): string {
1393 if ( !$list ) {
1394 return '';
1395 }
1396 if ( $sort ) {
1397 sort( $list );
1398 }
1399
1400 return $this->getLanguage()
1401 ->listToText( array_map( self::arrayToString( ... ), $list ) );
1402 }
1403
1413 public static function arrayToString( $list ) {
1414 if ( is_array( $list ) && count( $list ) == 1 ) {
1415 $list = $list[0];
1416 }
1417 if ( $list instanceof Closure ) {
1418 // Don't output stuff like "Closure$;1028376090#8$48499d94fe0147f7c633b365be39952b$"
1419 return 'Closure';
1420 } elseif ( is_object( $list ) ) {
1421 return wfMessage( 'parentheses' )->params( get_class( $list ) )->escaped();
1422 } elseif ( !is_array( $list ) ) {
1423 return $list;
1424 } else {
1425 if ( is_object( $list[0] ) ) {
1426 $class = get_class( $list[0] );
1427 } else {
1428 $class = $list[0];
1429 }
1430
1431 return wfMessage( 'parentheses' )->params( "$class, {$list[1]}" )->escaped();
1432 }
1433 }
1434
1439 public function getEntryPointInfo() {
1440 $config = $this->getConfig();
1441 $scriptPath = $config->get( MainConfigNames::ScriptPath ) ?: '/';
1442
1443 $entryPoints = [
1444 'version-entrypoints-articlepath' => $config->get( MainConfigNames::ArticlePath ),
1445 'version-entrypoints-scriptpath' => $scriptPath,
1446 'version-entrypoints-index-php' => wfScript( 'index' ),
1447 'version-entrypoints-api-php' => wfScript( 'api' ),
1448 'version-entrypoints-rest-php' => wfScript( 'rest' ),
1449 ];
1450
1451 $language = $this->getLanguage();
1452 $thAttributes = [
1453 'dir' => $language->getDir(),
1454 'lang' => $language->getHtmlCode(),
1455 'scope' => 'col'
1456 ];
1457
1458 $this->addTocSection( id: 'mw-version-entrypoints', msg: 'version-entrypoints' );
1459
1460 $out = Html::element(
1461 'h2',
1462 [ 'id' => 'mw-version-entrypoints' ],
1463 $this->msg( 'version-entrypoints' )->text()
1464 ) .
1465 Html::openElement( 'table',
1466 [
1467 'class' => 'wikitable plainlinks',
1468 'id' => 'mw-version-entrypoints-table',
1469 'dir' => 'ltr',
1470 'lang' => 'en'
1471 ]
1472 ) .
1473 Html::openElement( 'thead' ) .
1474 Html::openElement( 'tr' ) .
1476 'th',
1477 $thAttributes,
1478 $this->msg( 'version-entrypoints-header-entrypoint' )->text()
1479 ) .
1481 'th',
1482 $thAttributes,
1483 $this->msg( 'version-entrypoints-header-url' )->text()
1484 ) .
1485 Html::closeElement( 'tr' ) .
1486 Html::closeElement( 'thead' );
1487
1488 foreach ( $entryPoints as $message => $value ) {
1489 $url = $this->urlUtils->expand( $value, PROTO_RELATIVE );
1490 $out .= Html::openElement( 'tr' ) .
1491 Html::rawElement( 'td', [], $this->msg( $message )->parse() ) .
1492 Html::rawElement( 'td', [],
1493 Html::rawElement(
1494 'code',
1495 [],
1496 $this->msg( new RawMessage( "[$url $value]" ) )->parse()
1497 )
1498 ) .
1499 Html::closeElement( 'tr' );
1500 }
1501
1502 $out .= Html::closeElement( 'table' );
1503
1504 return $out;
1505 }
1506
1511 protected function getGroupName() {
1512 return 'wiki';
1513 }
1514}
1515
1516// @codeCoverageIgnoreStart
1521class_alias( SpecialVersion::class, 'SpecialVersion' );
1522// @codeCoverageIgnoreEnd
const CACHE_ANYTHING
Definition Defines.php:72
const MW_VERSION
The running version of MediaWiki.
Definition Defines.php:23
const PROTO_RELATIVE
Definition Defines.php:219
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.
$scriptPath
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:72
This class provides an implementation of the core hook interfaces, forwarding hook calls to HookConta...
static closeElement( $element)
Returns "</$element>".
Definition Html.php:345
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml\element()).
Definition Html.php:284
Variant of the Message class.
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().
static getInstance()
Returns the global default instance of the top level service locator.
static listParam(array $list, $type=ListType::AND)
Definition Message.php:1355
Load JSON files, and uses a Processor to extract information.
getAllThings()
Get credits information about all installed extensions and skins.
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.
Version information about MediaWiki (core, extensions, libs), PHP, and the database.
getParserFunctionHooks()
Obtains a list of installed parser function hooks and the associated H2 header.
getLibraries(array $credits)
Generate the section for installed external libraries.
getParsoidModules()
Obtains a list of installed Parsoid Modules and the associated H2 header.
static parseComposerInstalled(array $credits)
string $coreId
The current rev id/SHA hash of MediaWiki core.
static arrayToString( $list)
Convert an array or object to a string for display.
static getVersion( $flags='', $lang=null)
Return a string of the MediaWiki version with Git revision if available.
listAuthors( $authors, $extName, $extDir)
Return a formatted unsorted list of authors.
getCreditsForExtension( $type, array $extension)
Creates and formats a version line for a single extension.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getExtensionCategory( $type, ?string $text, array $creditsGroup)
Creates and returns the HTML for a single extension category.
static getExtensionTypes()
Returns an array with the base extension types.
static getCopyrightAndAuthorList()
Get the "MediaWiki is copyright 2001-20xx by lots of cool folks" text.
getEntryPointInfo()
Get the list of entry points and their URLs.
static getCredits(ExtensionRegistry $reg, Config $conf)
__construct(private readonly ParserFactory $parserFactory, private readonly UrlUtils $urlUtils, private readonly IConnectionProvider $dbProvider)
static string[] false $extensionTypes
Lazy initialized key/value with message content.
getParserTags()
Obtains a list of installed parser tags and the associated H2 header.
getExternalLibraries(array $credits)
Generate an HTML table for external libraries that are installed.
Fetch status information from a local git repository.
Definition GitInfo.php:33
A service to expand, parse, and otherwise manipulate URLs.
Definition UrlUtils.php:16
Reads an installed.json file and provides accessors to get what is installed.
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:18
Interface for configuration instances.
Definition Config.php:18
Provide primary and replica IDatabase connections.
$source
element(SerializerNode $parent, SerializerNode $node, $contents)
addTocSection(string $id, string $msg,... $params)
Add a section to the table of contents.
addTocSubSection(string $id, string $msg,... $params)
Add a sub-section to the table of contents.
msg( $key,... $params)