From: Antoine Musso Date: Fri, 11 May 2012 18:13:09 +0000 (-0700) Subject: setting to completely override server hostname X-Git-Tag: 1.31.0-rc.0~23204^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=4d1324f47df62969a9ee2b69ce8ed02332aa93ce;p=lhc%2Fweb%2Fwiklou.git setting to completely override server hostname Labs has instances hostnames forged in sequences which make them not that much useful for human readable output. Labs does publish a meaningful instance name as an env variable though, so we could use it to get better output. This patch introduce $wgOverrideHostname (default false) which when set will override the hostname returned by wfHostname(). Change-Id: Ibdba007cc4025fa0b0ebef39b5669c32852a95a7 --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 6e59a86eb9..35ae6bda3c 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4186,6 +4186,13 @@ $wgLogExceptionBacktrace = true; */ $wgShowHostnames = false; +/** + * Override server hostname detection with a hardcoded value. + * Should be a string, default false. + * @since 1.20 + */ +$wgOverrideHostname = false; + /** * If set to true MediaWiki will throw notices for some possible error * conditions and for deprecated functions. diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index ba9bf74556..7e759580de 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1758,6 +1758,15 @@ function wfDebugDieBacktrace( $msg = '' ) { function wfHostname() { static $host; if ( is_null( $host ) ) { + + # Hostname overriding + global $wgOverrideHostname; + if( $wgOverrideHostname !== false ) { + # Set static and skip any detection + $host = $wgOverrideHostname; + return $host; + } + if ( function_exists( 'posix_uname' ) ) { // This function not present on Windows $uname = posix_uname();