mediawiki.toc: Clean up left overs
[mediawiki.git] / includes / MediaWikiVersionFetcher.php
blob17cb8aa451280ab44390b40d3de5a21a420235b5
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];