MediaWiki REL1_39
version.php
Go to the documentation of this file.
1<?php
26require_once __DIR__ . '/Maintenance.php';
27
31class Version extends Maintenance {
32 public function __construct() {
33 parent::__construct();
34 $this->addDescription( 'Prints the current version of MediaWiki' );
35 }
36
37 public function execute() {
38 if ( !defined( 'MW_VERSION' ) ) {
39 $this->fatalError( "MediaWiki version not defined or unknown" );
40 }
41
42 global $IP;
43 $contentLang = \MediaWiki\MediaWikiServices::getInstance()->getContentLanguage();
44
45 $version = MW_VERSION;
46 $strictVersion = substr( $version, 0, 4 );
47 $isLTS = false;
48
49 // See: https://www.mediawiki.org/wiki/Topic:U4u94htjqupsosea
50 if ( $strictVersion >= '1.19' ) {
51 $x = (float)explode( '.', $strictVersion )[1];
52 $isLTS = ( $x - 19 ) % 4 === 0;
53 }
54
55 // Get build date and append if available
56 $gitInfo = new GitInfo( $IP );
57 $gitHeadCommitDate = $gitInfo->getHeadCommitDate();
58 $buildDate = $contentLang->timeanddate( (string)$gitHeadCommitDate, true );
59
60 $text = "MediaWiki version: " . $version;
61 if ( $isLTS ) {
62 $text .= " LTS";
63 }
64 if ( $buildDate ) {
65 $text .= " (built: $buildDate)";
66 }
67
68 $this->output( $text . "\n" );
69 }
70}
71
72$maintClass = Version::class;
73require_once RUN_MAINTENANCE_IF_MAIN;
const MW_VERSION
The running version of MediaWiki.
Definition Defines.php:36
if(!defined( 'MEDIAWIKI')) if(ini_get('mbstring.func_overload')) if(!defined( 'MW_ENTRY_POINT')) global $IP
Environment checks.
Definition Setup.php:91
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
output( $out, $channel=null)
Throw some output to the user.
addDescription( $text)
Set the description text.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
execute()
Do the actual work.
Definition version.php:37
__construct()
Default constructor.
Definition version.php:32
$maintClass
Definition version.php:72