| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
namespace MediaWiki\Maintenance; |
| 27 |
|
| 28 |
use MediaWiki\Utils\GitInfo; |
| 29 |
|
| 30 |
|
| 31 |
require_once __DIR__ . '/Maintenance.php'; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
class Version extends Maintenance { |
| 38 |
public function __construct() { |
| 39 |
parent::__construct(); |
| 40 |
$this->addDescription( 'Prints the current version of MediaWiki' ); |
| 41 |
} |
| 42 |
|
| 43 |
public function canExecuteWithoutLocalSettings(): bool { |
| 44 |
return true; |
| 45 |
} |
| 46 |
|
| 47 |
public function execute() { |
| 48 |
if ( !defined( 'MW_VERSION' ) ) { |
| 49 |
$this->fatalError( "MediaWiki version not defined or unknown" ); |
| 50 |
} |
| 51 |
|
| 52 |
global $IP; |
| 53 |
$contentLang = $this->getServiceContainer()->getContentLanguage(); |
| 54 |
|
| 55 |
$version = MW_VERSION; |
| 56 |
$strictVersion = substr( $version, 0, 4 ); |
| 57 |
$isLTS = false; |
| 58 |
|
| 59 |
|
| 60 |
if ( $strictVersion >= '1.19' ) { |
| 61 |
$x = (float)explode( '.', $strictVersion )[1]; |
| 62 |
$isLTS = ( $x - 19 ) % 4 === 0; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
$gitInfo = new GitInfo( $IP ); |
| 67 |
$gitHeadCommitDate = $gitInfo->getHeadCommitDate(); |
| 68 |
$buildDate = $contentLang->timeanddate( (string)$gitHeadCommitDate, true ); |
| 69 |
|
| 70 |
$text = "MediaWiki version: " . $version; |
| 71 |
if ( $isLTS ) { |
| 72 |
$text .= " LTS"; |
| 73 |
} |
| 74 |
if ( $buildDate ) { |
| 75 |
$text .= " (built: $buildDate)"; |
| 76 |
} |
| 77 |
|
| 78 |
$this->output( $text . "\n" ); |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
$maintClass = Version::class; |
| 84 |
require_once RUN_MAINTENANCE_IF_MAIN; |
| 85 |
|