Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / MediaWikiVersionFetcher.php
blobc3fb4869adc62025e79085c956aaf5e041a46a5f
1 <?php
3 /**
4 * Provides access to MediaWiki's version without requiring MediaWiki (or anything else)
5 * being loaded first.
7 * @licence GNU GPL v2+
8 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
9 */
10 class MediaWikiVersionFetcher {
12 /**
13 * Returns the MediaWiki version, in the format used by MediaWiki's wgVersion global.
15 * @return string
16 * @throws RuntimeException
18 public function fetchVersion() {
19 $defaultSettings = file_get_contents( __DIR__ . '/DefaultSettings.php' );
21 $matches = array();
22 preg_match( "/wgVersion = '([0-9a-zA-Z\.\-]+)';/", $defaultSettings, $matches );
24 if ( count( $matches ) !== 2 ) {
25 throw new RuntimeException( 'Could not extract the MediaWiki version from DefaultSettings.php' );
28 return $matches[1];