ApiParse: don't reparse language link titles
[mediawiki.git] / maintenance / Version.php
blobdbd8c3c78d18e1715ce5f41328da32c36c065d4e
1 <?php
2 /**
3 * Prints the version of MediaWiki.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup Maintenance
22 * @author Derick Alangi
23 * @since 1.36
26 namespace MediaWiki\Maintenance;
28 use Maintenance;
29 use MediaWiki\Utils\GitInfo;
31 // @codeCoverageIgnoreStart
32 require_once __DIR__ . '/Maintenance.php';
33 // @codeCoverageIgnoreEnd
35 /**
36 * @ingroup Maintenance
38 class Version extends Maintenance {
39 public function __construct() {
40 parent::__construct();
41 $this->addDescription( 'Prints the current version of MediaWiki' );
44 public function canExecuteWithoutLocalSettings(): bool {
45 return true;
48 public function execute() {
49 if ( !defined( 'MW_VERSION' ) ) {
50 $this->fatalError( "MediaWiki version not defined or unknown" );
53 global $IP;
54 $contentLang = $this->getServiceContainer()->getContentLanguage();
56 $version = MW_VERSION;
57 $strictVersion = substr( $version, 0, 4 );
58 $isLTS = false;
60 // See: https://www.mediawiki.org/wiki/Topic:U4u94htjqupsosea
61 if ( $strictVersion >= '1.19' ) {
62 $x = (float)explode( '.', $strictVersion )[1];
63 $isLTS = ( $x - 19 ) % 4 === 0;
66 // Get build date and append if available
67 $gitInfo = new GitInfo( $IP );
68 $gitHeadCommitDate = $gitInfo->getHeadCommitDate();
69 $buildDate = $contentLang->timeanddate( (string)$gitHeadCommitDate, true );
71 $text = "MediaWiki version: " . $version;
72 if ( $isLTS ) {
73 $text .= " LTS";
75 if ( $buildDate ) {
76 $text .= " (built: $buildDate)";
79 $this->output( $text . "\n" );
83 // @codeCoverageIgnoreStart
84 $maintClass = Version::class;
85 require_once RUN_MAINTENANCE_IF_MAIN;
86 // @codeCoverageIgnoreEnd