X-Git-Url: http://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FMediaWikiVersionFetcher.php;h=5bfac45c7d5feee22cbea21402789572864de689;hp=943bc9fcf32ca969629ec07f039235fa6073017d;hb=0841683695523a707a6e91a932209df8dbcd0248;hpb=9440d5228fb44b0217c7fa9e46874152f223a0c2 diff --git a/includes/MediaWikiVersionFetcher.php b/includes/MediaWikiVersionFetcher.php index 943bc9fcf3..5bfac45c7d 100644 --- a/includes/MediaWikiVersionFetcher.php +++ b/includes/MediaWikiVersionFetcher.php @@ -9,19 +9,19 @@ class MediaWikiVersionFetcher { /** - * Returns the MediaWiki version, in the format used by MediaWiki's wgVersion global. + * Get the MediaWiki version, extracted from the PHP source file where it is defined. * * @return string * @throws RuntimeException */ public function fetchVersion() { - $defaultSettings = file_get_contents( __DIR__ . '/DefaultSettings.php' ); + $code = file_get_contents( __DIR__ . '/Defines.php' ); - $matches = array(); - preg_match( "/wgVersion = '([0-9a-zA-Z\.\-]+)';/", $defaultSettings, $matches ); + $matches = []; + preg_match( "/define\( 'MW_VERSION', '([0-9a-zA-Z\.\-]+)'/", $code, $matches ); if ( count( $matches ) !== 2 ) { - throw new RuntimeException( 'Could not extract the MediaWiki version from DefaultSettings.php' ); + throw new RuntimeException( 'Could not extract the MediaWiki version from Defines.php' ); } return $matches[1];