[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/ -> MediaWikiVersionFetcher.php (source)

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


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1