From 3114dbea0413f89ffcef57a9678bd53dd7b0078c Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Mon, 1 Sep 2014 22:26:36 +0200 Subject: [PATCH] Replace $wgConf->localVHosts by $wgLocalVirtualHosts The former is independent of the remaining of the SiteConfiguration class, and as thus makes more sense to be defined as an explicit configuration setting rather that being hidden in $wgConf. Change-Id: I25204d37c5cfffb6953fe53e14316dc3df5b5b10 --- RELEASE-NOTES-1.25 | 1 + includes/DefaultSettings.php | 12 ++++++++++++ includes/HttpFunctions.php | 8 +++++--- includes/SiteConfiguration.php | 4 ++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25 index a21b684c1a..db4c124625 100644 --- a/RELEASE-NOTES-1.25 +++ b/RELEASE-NOTES-1.25 @@ -10,6 +10,7 @@ production. === Configuration changes in 1.25 === * $wgPageShowWatchingUsers was removed. +* $wgLocalVirtualHosts has been added to replace $wgConf->localVHosts. === New features in 1.25 === * (bug 58139) ResourceLoaderFileModule now supports language fallback diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 510c1dd71c..c6e91cf2cf 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -7083,6 +7083,18 @@ $wgAsyncHTTPTimeout = 25; */ $wgHTTPProxy = false; +/** + * Local virtual hosts. + * + * This lists domains that are configured as virtual hosts on the same machine. + * If a request is to be made to a domain listed here, or any subdomain thereof, + * then no proxy will be used. + * Command-line scripts are not affected by this setting and will always use + * proxy if it is configured. + * @since 1.25 + */ +$wgLocalVirtualHosts = array(); + /** * Timeout for connections done internally (in seconds) * Only works for curl diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index 8302124570..f9ee14bbd9 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -114,7 +114,7 @@ class Http { * @return bool */ public static function isLocalURL( $url ) { - global $wgCommandLineMode, $wgConf; + global $wgCommandLineMode, $wgLocalVirtualHosts, $wgConf; if ( $wgCommandLineMode ) { return false; @@ -126,7 +126,7 @@ class Http { $host = $matches[1]; // Split up dotwise $domainParts = explode( '.', $host ); - // Check if this domain or any superdomain is listed in $wgConf as a local virtual host + // Check if this domain or any superdomain is listed as a local virtual host $domainParts = array_reverse( $domainParts ); $domain = ''; @@ -139,7 +139,9 @@ class Http { $domain = $domainPart . '.' . $domain; } - if ( $wgConf->isLocalVHost( $domain ) ) { + if ( in_array( $domain, $wgLocalVirtualHosts ) + || $wgConf->isLocalVHost( $domain ) + ) { return true; } } diff --git a/includes/SiteConfiguration.php b/includes/SiteConfiguration.php index 8c1f26b82a..c3b1a6ac7f 100644 --- a/includes/SiteConfiguration.php +++ b/includes/SiteConfiguration.php @@ -133,6 +133,8 @@ class SiteConfiguration { /** * Array of domains that are local and can be handled by the same server + * + * @deprecated since 1.25; use $wgLocalVirtualHosts instead. */ public $localVHosts = array(); @@ -565,6 +567,8 @@ class SiteConfiguration { /** * Returns true if the given vhost is handled locally. + * + * @deprecated since 1.25; check if the host is in $wgLocalVirtualHosts instead. * @param string $vhost * @return bool */ -- 2.20.1