wiki.techinc.nl/includes/MediaWikiVersionFetcher.php
umherirrender 2000672ac3 Fixed spacing
- Added spaces after if/foreach/catch
- Added new line before end of file
- Added or removed spaces before/after parenthesis, comma
- Added spaces around string concat

Change-Id: I0590070f1b3542108e242730e8d9a3ba9831e94f
2014-03-20 20:37:30 +00:00

31 lines
773 B
PHP

<?php
/**
* Provides access to MediaWiki's version without requiring MediaWiki (or anything else)
* being loaded first.
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
class MediaWikiVersionFetcher {
/**
* Returns the MediaWiki version, in the format used by MediaWiki's wgVersion global.
*
* @return string
* @throws RuntimeException
*/
public function fetchVersion() {
$defaultSettings = file_get_contents( __DIR__ . '/DefaultSettings.php' );
$matches = array();
preg_match( "/wgVersion = '([0-9a-zA-Z\.]+)';/", $defaultSettings, $matches );
if ( count( $matches ) !== 2 ) {
throw new RuntimeException( 'Could not extract the MediaWiki version from DefaultSettings.php' );
}
return $matches[1];
}
}