From 4d1324f47df62969a9ee2b69ce8ed02332aa93ce Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Fri, 11 May 2012 11:13:09 -0700 Subject: [PATCH] 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 --- includes/DefaultSettings.php | 7 +++++++ includes/GlobalFunctions.php | 9 +++++++++ 2 files changed, 16 insertions(+) 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(); -- 2.20.1