2013-12-20 22:34:49 +00:00
|
|
|
<?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 {
|
|
|
|
|
|
|
|
|
|
/**
|
2020-02-25 01:28:12 +00:00
|
|
|
* Get the MediaWiki version, extracted from the PHP source file where it is defined.
|
2013-12-20 22:34:49 +00:00
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
*/
|
|
|
|
|
public function fetchVersion() {
|
2020-02-25 01:28:12 +00:00
|
|
|
$code = file_get_contents( __DIR__ . '/Defines.php' );
|
2013-12-20 22:34:49 +00:00
|
|
|
|
2019-01-15 16:54:44 +00:00
|
|
|
if ( !preg_match( "/define\( 'MW_VERSION', '([^']+)'/", $code, $matches ) ) {
|
2020-02-25 01:28:12 +00:00
|
|
|
throw new RuntimeException( 'Could not extract the MediaWiki version from Defines.php' );
|
2013-12-20 22:34:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $matches[1];
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-20 18:59:20 +00:00
|
|
|
}
|