* Implement MW_VERSION constant in Defines.php and use it in preference to $wgVersion...
authorHappy-melon <happy-melon@users.mediawiki.org>
Sat, 7 May 2011 14:53:08 +0000 (14:53 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Sat, 7 May 2011 14:53:08 +0000 (14:53 +0000)
* Move the declaration of $wgFeedClasses from Defines.php to WebStart.php

13 files changed:
includes/DefaultSettings.php
includes/Defines.php
includes/Export.php
includes/Feed.php
includes/GlobalFunctions.php
includes/HttpFunctions.php
includes/OutputPage.php
includes/Setup.php
includes/installer/DatabaseUpdater.php
includes/installer/WebInstallerOutput.php
includes/resourceloader/ResourceLoaderStartUpModule.php
includes/specials/SpecialVersion.php
tests/parserTests.php

index 7bc56f8..ec94af2 100644 (file)
@@ -33,8 +33,11 @@ if ( !defined( 'MW_COMPILED' ) ) {
 $wgConf = new SiteConfiguration;
 /** @endcond */
 
-/** MediaWiki version number */
-$wgVersion = '1.19alpha';
+/**
+ * MediaWiki version number
+ * @deprecated use the constant MW_VERSION instead
+ */
+$wgVersion = MW_VERSION;
 
 /** Name of the site. It must be changed in LocalSettings.php */
 $wgSitename         = 'MediaWiki';
@@ -4311,6 +4314,16 @@ $wgUseNPPatrol = true;
 /** Provide syndication feeds (RSS, Atom) for, e.g., Recentchanges, Newpages */
 $wgFeed = true;
 
+/**
+ * Available feeds objects
+ * Should probably only be defined when a page is syndicated ie when
+ * $wgOut->isSyndicated() is true
+ */
+$wgFeedClasses = array(
+       'rss' => 'RSSFeed',
+       'atom' => 'AtomFeed',
+);
+
 /** Set maximum number of results to return in syndication feeds (RSS, Atom) for
  * eg Recentchanges, Newpages. */
 $wgFeedLimit = 50;
index b4a8d7b..c226e55 100644 (file)
@@ -9,9 +9,10 @@
  * @file
  */
 
-/**
+/**@{
  * Version constants for the benefit of extensions
  */
+define( 'MW_VERSION', '1.19alpha' );
 define( 'MW_SPECIALPAGE_VERSION', 2 );
 
 /**@{
@@ -85,16 +86,6 @@ define( 'NS_IMAGE', NS_FILE );
 define( 'NS_IMAGE_TALK', NS_FILE_TALK );
 /**@}*/
 
-/**
- * Available feeds objects
- * Should probably only be defined when a page is syndicated ie when
- * $wgOut->isSyndicated() is true
- */
-$wgFeedClasses = array(
-       'rss' => 'RSSFeed',
-       'atom' => 'AtomFeed',
-);
-
 /**@{
  * Cache type
  */
index 3a9180a..ceda80b 100644 (file)
@@ -406,8 +406,7 @@ class XmlDumpWriter {
        }
 
        function generator() {
-               global $wgVersion;
-               return Xml::element( 'generator', array(), "MediaWiki $wgVersion" );
+               return Xml::element( 'generator', array(), "MediaWiki " . MW_VERSION );
        }
 
        function homelink() {
index 183b8e6..8535eaa 100644 (file)
@@ -301,7 +301,6 @@ class RSSFeed extends ChannelFeed {
         * Ouput an RSS 2.0 header
         */
        function outHeader() {
-               global $wgVersion;
 
                $this->outXmlHeader();
                ?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
@@ -310,7 +309,7 @@ class RSSFeed extends ChannelFeed {
                <link><?php print $this->getUrl() ?></link>
                <description><?php print $this->getDescription() ?></description>
                <language><?php print $this->getLanguage() ?></language>
-               <generator>MediaWiki <?php print $wgVersion ?></generator>
+               <generator>MediaWiki <?php print MW_VERSION ?></generator>
                <lastBuildDate><?php print $this->formatTime( wfTimestampNow() ) ?></lastBuildDate>
 <?php
        }
@@ -361,8 +360,6 @@ class AtomFeed extends ChannelFeed {
         * Outputs a basic header for Atom 1.0 feeds.
         */
        function outHeader() {
-               global $wgVersion;
-
                $this->outXmlHeader();
                ?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="<?php print $this->getLanguage() ?>">
                <id><?php print $this->getFeedId() ?></id>
@@ -371,7 +368,7 @@ class AtomFeed extends ChannelFeed {
                <link rel="alternate" type="text/html" href="<?php print $this->getUrl() ?>"/>
                <updated><?php print $this->formatTime( wfTimestampNow() ) ?>Z</updated>
                <subtitle><?php print $this->getDescription() ?></subtitle>
-               <generator>MediaWiki <?php print $wgVersion ?></generator>
+               <generator>MediaWiki <?php print MW_VERSION ?></generator>
 
 <?php
        }
index ef7ead9..bc87b93 100644 (file)
@@ -2500,10 +2500,8 @@ function wfUsePHP( $req_ver ) {
  *                 a float
  */
 function wfUseMW( $req_ver ) {
-       global $wgVersion;
-
-       if ( version_compare( $wgVersion, (string)$req_ver, '<' ) ) {
-               throw new MWException( "MediaWiki $req_ver required--this is only $wgVersion" );
+       if ( version_compare( MW_VERSION, (string)$req_ver, '<' ) ) {
+               throw new MWException( "MediaWiki $req_ver required--this is only " . MW_VERSION );
        }
 }
 
index 841b341..72def79 100644 (file)
@@ -112,8 +112,7 @@ class Http {
         * @return String
         */
        public static function userAgent() {
-               global $wgVersion;
-               return "MediaWiki/$wgVersion";
+               return "MediaWiki/" . MW_VERSION;
        }
 
        /**
index 640b4a3..2c8bb23 100644 (file)
@@ -2683,7 +2683,7 @@ class OutputPage {
         */
        public function getHeadLinks( Skin $sk, $addContentType = false ) {
                global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI,
-                       $wgSitename, $wgVersion, $wgHtml5, $wgMimeType,
+                       $wgSitename, $wgHtml5, $wgMimeType,
                        $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes,
                        $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf,
                        $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgContLang,
@@ -2710,7 +2710,7 @@ class OutputPage {
 
                $tags[] = Html::element( 'meta', array(
                        'name' => 'generator',
-                       'content' => "MediaWiki $wgVersion",
+                       'content' => "MediaWiki " . MW_VERSION,
                ) );
 
                $p = "{$this->mIndexPolicy},{$this->mFollowPolicy}";
index 58b9002..63bfa54 100644 (file)
@@ -23,6 +23,7 @@ $fname = 'Setup.php';
 wfProfileIn( $fname );
 
 // Check to see if we are at the file scope
+// FIXME: use a different test here, maybe a constant defined at the top of DefaultSettings.php?
 if ( !isset( $wgVersion ) ) {
        echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
        die( 1 );
index 1ac60ff..6d50b92 100644 (file)
@@ -191,7 +191,6 @@ abstract class DatabaseUpdater {
         * @param $what Array: what updates to perform
         */
        public function doUpdates( $what = array( 'core', 'extensions', 'purge' ) ) {
-               global $wgVersion;
 
                $what = array_flip( $what );
                if ( isset( $what['core'] ) ) {
@@ -202,7 +201,7 @@ abstract class DatabaseUpdater {
                        $this->runUpdates( $this->getExtensionUpdates(), true );
                }
 
-               $this->setAppliedUpdates( $wgVersion, $this->updates );
+               $this->setAppliedUpdates( MW_VERSION, $this->updates );
 
                if( isset( $what['purge'] ) ) {
                        $this->purgeCache();
index 443cf5a..7366888 100644 (file)
@@ -270,8 +270,7 @@ class WebInstallerOutput {
        }
 
        public function outputTitle() {
-               global $wgVersion;
-               echo htmlspecialchars( wfMsg( 'config-title', $wgVersion ) );
+               echo htmlspecialchars( wfMsg( 'config-title', MW_VERSION ) );
        }
 
        public function getJQuery() {
index 1f66c88..73961f4 100644 (file)
@@ -35,7 +35,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
        protected function getConfig( $context ) {
                global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, 
                        $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, 
-                       $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, 
+                       $wgVariantArticlePath, $wgActionPaths, $wgUseAjax,
                        $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest, 
                        $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgProto,
                        $wgCookiePrefix, $wgResourceLoaderMaxQueryLength;
@@ -71,7 +71,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgServer' => $wgServer,
                        'wgUserLanguage' => $context->getLanguage(),
                        'wgContentLanguage' => $wgContLang->getCode(),
-                       'wgVersion' => $wgVersion,
+                       'wgVersion' => MW_VERSION,
                        'wgEnableAPI' => $wgEnableAPI,
                        'wgEnableWriteAPI' => $wgEnableWriteAPI,
                        'wgDefaultDateFormat' => $wgContLang->getDefaultDateFormat(),
index 0c09c26..671ae89 100644 (file)
@@ -158,16 +158,16 @@ class SpecialVersion extends SpecialPage {
         * @return mixed
         */
        public static function getVersion( $flags = '' ) {
-               global $wgVersion, $IP;
+               global $IP;
                wfProfileIn( __METHOD__ );
 
                $info = self::getSvnInfo( $IP );
                if ( !$info ) {
-                       $version = $wgVersion;
+                       $version = MW_VERSION;
                } elseif( $flags === 'nodb' ) {
-                       $version = "$wgVersion (r{$info['checkout-rev']})";
+                       $version = MW_VERSION . " (r{$info['checkout-rev']})";
                } else {
-                       $version = $wgVersion . ' ' .
+                       $version = MW_VERSION . ' ' .
                                wfMsg(
                                        'version-svn-revision',
                                        isset( $info['directory-rev'] ) ? $info['directory-rev'] : '',
@@ -186,11 +186,13 @@ class SpecialVersion extends SpecialPage {
         * @return mixed
         */
        public static function getVersionLinked() {
-               global $wgVersion, $IP;
+               global $IP;
                wfProfileIn( __METHOD__ );
 
                $info = self::getSvnInfo( $IP );
 
+               $version = MW_VERSION;
+
                if ( isset( $info['checkout-rev'] ) ) {
                        $linkText = wfMsg(
                                'version-svn-revision',
@@ -199,12 +201,10 @@ class SpecialVersion extends SpecialPage {
                        );
 
                        if ( isset( $info['viewvc-url'] ) ) {
-                               $version = "$wgVersion [{$info['viewvc-url']} $linkText]";
+                               $version .= " [{$info['viewvc-url']} $linkText]";
                        } else {
-                               $version = "$wgVersion $linkText";
+                               $version .= " $linkText";
                        }
-               } else {
-                       $version = $wgVersion;
                }
 
                wfProfileOut( __METHOD__ );
@@ -680,9 +680,10 @@ class SpecialVersion extends SpecialPage {
 
        function showEasterEgg() {
                $rx = $rp = $xe = '';
+               $version = MW_VERSION;
                $alpha = array("", "kbQW", "\$\n()");
                $beta = implode( "', '", $alpha);
-               $juliet = 'echo $delta + strrev($foxtrot) - $alfa + $wgVersion . base64_decode($bravo) * $charlie';
+               $juliet = 'echo $delta + strrev($foxtrot) - $alfa + $version . base64_decode($bravo) * $charlie';
                for ( $i = 1; $i <= 4; $i++ ) {
                        $rx .= '([^j]*)J';
                        $rp .= "+(\\$i)";
index 580f6fb..761ba49 100644 (file)
@@ -30,8 +30,9 @@ $optionsWithArgs = array( 'regex', 'seed', 'setversion' );
 require_once( dirname( __FILE__ ) . '/../maintenance/commandLine.inc' );
 
 if ( isset( $options['help'] ) ) {
+       $version = MW_VERSION;
        echo <<<ENDS
-MediaWiki $wgVersion parser test suite
+MediaWiki $version parser test suite
 Usage: php parserTests.php [options...]
 
 Options: