Update IPSet use statements
[lhc/web/wiklou.git] / includes / MediaWikiVersionFetcher.php
1 <?php
2
3 /**
4 * Provides access to MediaWiki's version without requiring MediaWiki (or anything else)
5 * being loaded first.
6 *
7 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
8 */
9 class MediaWikiVersionFetcher {
10
11 /**
12 * Returns the MediaWiki version, in the format used by MediaWiki's wgVersion global.
13 *
14 * @return string
15 * @throws RuntimeException
16 */
17 public function fetchVersion() {
18 $defaultSettings = file_get_contents( __DIR__ . '/DefaultSettings.php' );
19
20 $matches = [];
21 preg_match( "/wgVersion = '([0-9a-zA-Z\.\-]+)';/", $defaultSettings, $matches );
22
23 if ( count( $matches ) !== 2 ) {
24 throw new RuntimeException( 'Could not extract the MediaWiki version from DefaultSettings.php' );
25 }
26
27 return $matches[1];
28 }
29
30 }