Removed $wgProto. Previously, setting this undocumented global variable to anything...
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 16 Jun 2011 05:13:29 +0000 (05:13 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 16 Jun 2011 05:13:29 +0000 (05:13 +0000)
Exposing it in the default LocalSettings.php as I did in r90105 was not a good solution, really the only way to avoid breakage is to just get the protocol from $wgServer whenever you need the protocol.

Fixed $wgCookieSecure so that it will be enabled automatically if the user sets $wgServer to an https URL in LocalSettings.php. Added documentation for other cookie-related globals.

Grep indicates that $wgProto is not used by any extensions. $wgCookieSecure is used, hence the need for the Setup.php patch.

RELEASE-NOTES-1.18
includes/DefaultSettings.php
includes/GlobalFunctions.php
includes/Setup.php
includes/SkinTemplate.php
includes/installer/Installer.php
includes/installer/LocalSettingsGenerator.php
includes/resourceloader/ResourceLoaderStartUpModule.php

index 9afb57b..a6f20c7 100644 (file)
@@ -61,6 +61,8 @@ production.
 * The spyc library is now no longer included in phase3.
 * (bug 28343) Unused preferences contextlines/contextchars have been removed
 * $wgSkinExtensionFunctions has been removed. Use $wgExtensionFunctions instead.
+* $wgProto has been removed. You now only need to set $wgServer to change the 
+  URL protocol.
 
 === New features in 1.18 ===
 * (bug 8130) Query pages should limit to content namespaces, not just main
index 5dd6d63..d255994 100644 (file)
@@ -3744,13 +3744,34 @@ $wgCookieExpiration = 30*86400;
  * or ".any.subdomain.net"
  */
 $wgCookieDomain = '';
+
+
+/**
+ * Set this variable if you want to restrict cookies to a certain path within 
+ * the domain specified by $wgCookieDomain.
+ */
 $wgCookiePath = '/';
-$wgCookieSecure = ($wgProto == 'https');
+
+/**
+ * Whether the "secure" flag should be set on the cookie. This can be:
+ *   - true:      Set secure flag
+ *   - false:     Don't set secure flag
+ *   - "detect":  Set the secure flag if $wgServer is set to an HTTPS URL
+ */
+$wgCookieSecure = 'detect';
+
+/**
+ * By default, MediaWiki checks if the client supports cookies during the 
+ * login process, so that it can display an informative error message if 
+ * cookies are disabled. Set this to true if you want to disable this cookie
+ * check.
+ */
 $wgDisableCookieCheck = false;
 
 /**
- * Set $wgCookiePrefix to use a custom one. Setting to false sets the default of
- * using the database name.
+ * Cookies generated by MediaWiki have names starting with this prefix. Set it
+ * to a string to use a custom prefix. Setting it to false causes the database
+ * name to be used as a prefix.
  */
 $wgCookiePrefix = false;
 
index 24fdab1..022f69c 100644 (file)
@@ -1573,7 +1573,7 @@ function wfAppendQuery( $url, $query ) {
 
 /**
  * Expand a potentially local URL to a fully-qualified URL.  Assumes $wgServer
- * and $wgProto are correct.
+ * is correct.
  *
  * @todo this won't work with current-path-relative URLs
  * like "subdir/foo.html", etc.
@@ -1582,11 +1582,12 @@ function wfAppendQuery( $url, $query ) {
  * @return string Fully-qualified URL
  */
 function wfExpandUrl( $url ) {
+       global $wgServer;
        if( substr( $url, 0, 2 ) == '//' ) {
-               global $wgProto;
-               return $wgProto . ':' . $url;
+               $bits = wfParseUrl( $wgServer );
+               $scheme = $bits ? $bits['scheme'] : 'http';
+               return $scheme . ':' . $url;
        } elseif( substr( $url, 0, 1 ) == '/' ) {
-               global $wgServer;
                return $wgServer . $url;
        } else {
                return $url;
index 0cc4056..4f975f1 100644 (file)
@@ -321,6 +321,10 @@ if ( $wgNewUserLog ) {
        $wgLogActions['newusers/autocreate'] = 'newuserlog-autocreate-entry';
 }
 
+if ( $wgCookieSecure === 'detect' ) {
+       $wgCookieSecure = ( substr( $wgServer, 0, 6 ) === 'https:' );
+}
+
 if ( !defined( 'MW_COMPILED' ) ) {
        if ( !MWInit::classExists( 'AutoLoader' ) ) {
                require_once( "$IP/includes/AutoLoader.php" );
index 5e189c1..3f90a2e 100644 (file)
@@ -666,8 +666,8 @@ class SkinTemplate extends Skin {
                                        'active' => $title->isSpecial( 'Userlogin' ) && $is_signup
                                );
                        }
-                       global $wgProto, $wgSecureLogin;
-                       if( $wgProto === 'http' && $wgSecureLogin ) {
+                       global $wgServer, $wgSecureLogin;
+                       if( substr( $wgServer, 0, 5 ) === 'http:' && $wgSecureLogin ) {
                                $title = SpecialPage::getTitleFor( 'Userlogin' );
                                $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL() );
                                $login_url['href']  = $https_url;
index 2bee742..1d2a938 100644 (file)
@@ -133,7 +133,6 @@ abstract class Installer {
                'wgImageMagickConvertCommand',
                'IP',
                'wgServer',
-               'wgProto',
                'wgScriptPath',
                'wgScriptExtension',
                'wgMetaNamespace',
@@ -878,7 +877,6 @@ abstract class Installer {
                $server = $proto . '://' . IP::combineHostAndPort( $host, $port, $stdPort );
                $this->showMessage( 'config-using-server', $server );
                $this->setVar( 'wgServer', $server );
-               $this->setVar( 'wgProto', $proto );
        }
 
        /**
index 7605674..41b345f 100644 (file)
@@ -39,7 +39,7 @@ class LocalSettingsGenerator {
 
                $confItems = array_merge(
                        array(
-                               'wgServer', 'wgProto', 'wgScriptPath', 'wgScriptExtension',
+                               'wgServer', 'wgScriptPath', 'wgScriptExtension',
                                'wgPasswordSender', 'wgImageMagickConvertCommand', 'wgShellLocale',
                                'wgLanguageCode', 'wgEnableEmail', 'wgEnableUserEmail', 'wgDiff3',
                                'wgEnotifUserTalk', 'wgEnotifWatchlist', 'wgEmailAuthentication',
@@ -249,12 +249,9 @@ if ( !defined( 'MEDIAWIKI' ) ) {
 \$wgScriptPath       = \"{$this->values['wgScriptPath']}\";
 \$wgScriptExtension  = \"{$this->values['wgScriptExtension']}\";
 
-## The server name to use in fully-qualified URLs
+## The protocol and server name to use in fully-qualified URLs
 \$wgServer           = \"{$this->values['wgServer']}\";
 
-## The URL protocol, may be http or https
-\$wgProto            = \"{$this->values['wgProto']}\";
-
 ## The relative URL path to the skins directory
 \$wgStylePath        = \"\$wgScriptPath/skins\";
 
index 206affd..90963b1 100644 (file)
@@ -37,7 +37,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang,
                        $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, 
                        $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest,
-                       $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgProto,
+                       $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath,
                        $wgCookiePrefix, $wgResourceLoaderMaxQueryLength, $wgLegacyJavaScriptGlobals;
 
                // Pre-process information
@@ -63,6 +63,9 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        $namespaceIds[$wgContLang->lc( $name )] = $index;
                }
 
+               $serverBits = wfParseUrl( $wgServer );
+               $protocol = $serverBits ? $serverBits['scheme'] : 'http';
+
                // Build list of variables
                $vars = array(
                        'wgLoadScript' => $wgLoadScript,
@@ -98,7 +101,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgFileCanRotate' => BitmapHandler::canRotate(),
                        'wgAvailableSkins' => Skin::getSkinNames(),
                        'wgExtensionAssetsPath' => $wgExtensionAssetsPath,
-                       'wgProto' => $wgProto,
+                       'wgProto' => $protocol,
                        // MediaWiki sets cookies to have this prefix by default
                        'wgCookiePrefix' => $wgCookiePrefix,
                        'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength,