blob: eb5ec78c826a3463da2d71dd38e4ddb197c2f6f8 (
plain) (
blame)
1
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
27
|
<?php
/**
* Provides access to MediaWiki's version without requiring MediaWiki (or anything else)
* being loaded first.
*
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
class MediaWikiVersionFetcher {
/**
* Get the MediaWiki version, extracted from the PHP source file where it is defined.
*
* @return string
* @throws RuntimeException
*/
public function fetchVersion() {
$code = file_get_contents( __DIR__ . '/Defines.php' );
if ( !preg_match( "/define\( 'MW_VERSION', '([^']+)'/", $code, $matches ) ) {
throw new RuntimeException( 'Could not extract the MediaWiki version from Defines.php' );
}
return $matches[1];
}
}
|