From: Tim Starling Date: Thu, 16 Jun 2011 05:13:29 +0000 (+0000) Subject: Removed $wgProto. Previously, setting this undocumented global variable to anything... X-Git-Tag: 1.31.0-rc.0~29502 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=9420ff446e8e63bb3eb782e66369f43bdd9b4d2a;p=lhc%2Fweb%2Fwiklou.git Removed $wgProto. Previously, setting this undocumented global variable to anything other than the part of $wgServer before the first colon would cause various things to subtly screw up. Similarly, forgetting to set it when you override $wgServer in LocalSettings.php would break things too. 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. --- diff --git a/RELEASE-NOTES-1.18 b/RELEASE-NOTES-1.18 index 9afb57b0b0..a6f20c730c 100644 --- a/RELEASE-NOTES-1.18 +++ b/RELEASE-NOTES-1.18 @@ -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 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 5dd6d63b2e..d255994674 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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; diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 24fdab1bb2..022f69c6ea 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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; diff --git a/includes/Setup.php b/includes/Setup.php index 0cc4056b68..4f975f16cf 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -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" ); diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 5e189c1a25..3f90a2eaf4 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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; diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 2bee742db3..1d2a9387b8 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -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 ); } /** diff --git a/includes/installer/LocalSettingsGenerator.php b/includes/installer/LocalSettingsGenerator.php index 76056748df..41b345fae3 100644 --- a/includes/installer/LocalSettingsGenerator.php +++ b/includes/installer/LocalSettingsGenerator.php @@ -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\"; diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index 206affd8d1..90963b1bfe 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -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,