Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 21 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| Version | |
0.00% |
0 / 21 |
|
0.00% |
0 / 3 |
56 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| canExecuteWithoutLocalSettings | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| execute | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Prints the version of MediaWiki. |
| 4 | * |
| 5 | * @license GPL-2.0-or-later |
| 6 | * @file |
| 7 | * @ingroup Maintenance |
| 8 | * @author Derick Alangi |
| 9 | * @since 1.36 |
| 10 | */ |
| 11 | |
| 12 | namespace MediaWiki\Maintenance; |
| 13 | |
| 14 | use MediaWiki\Utils\GitInfo; |
| 15 | |
| 16 | // @codeCoverageIgnoreStart |
| 17 | require_once __DIR__ . '/Maintenance.php'; |
| 18 | // @codeCoverageIgnoreEnd |
| 19 | |
| 20 | /** |
| 21 | * @ingroup Maintenance |
| 22 | */ |
| 23 | class Version extends Maintenance { |
| 24 | public function __construct() { |
| 25 | parent::__construct(); |
| 26 | $this->addDescription( 'Prints the current version of MediaWiki' ); |
| 27 | } |
| 28 | |
| 29 | public function canExecuteWithoutLocalSettings(): bool { |
| 30 | return true; |
| 31 | } |
| 32 | |
| 33 | public function execute() { |
| 34 | if ( !defined( 'MW_VERSION' ) ) { |
| 35 | $this->fatalError( "MediaWiki version not defined or unknown" ); |
| 36 | } |
| 37 | |
| 38 | global $IP; |
| 39 | $contentLang = $this->getServiceContainer()->getContentLanguage(); |
| 40 | |
| 41 | $version = MW_VERSION; |
| 42 | $strictVersion = substr( $version, 0, 4 ); |
| 43 | $isLTS = false; |
| 44 | |
| 45 | // See: https://www.mediawiki.org/wiki/Topic:U4u94htjqupsosea |
| 46 | if ( $strictVersion >= '1.19' ) { |
| 47 | $x = (int)explode( '.', $strictVersion )[1]; |
| 48 | $isLTS = ( $x - 19 ) % 4 === 0; |
| 49 | } |
| 50 | |
| 51 | // Get build date and append if available |
| 52 | $gitInfo = new GitInfo( $IP ); |
| 53 | $gitHeadCommitDate = $gitInfo->getHeadCommitDate(); |
| 54 | $buildDate = $contentLang->timeanddate( (string)$gitHeadCommitDate, true ); |
| 55 | |
| 56 | $text = "MediaWiki version: " . $version; |
| 57 | if ( $isLTS ) { |
| 58 | $text .= " LTS"; |
| 59 | } |
| 60 | if ( $buildDate ) { |
| 61 | $text .= " (built: $buildDate)"; |
| 62 | } |
| 63 | |
| 64 | $this->output( $text . "\n" ); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | // @codeCoverageIgnoreStart |
| 69 | $maintClass = Version::class; |
| 70 | require_once RUN_MAINTENANCE_IF_MAIN; |
| 71 | // @codeCoverageIgnoreEnd |