From 90ed80443e772dc5d83e74abc6a536acaa873fd3 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Mon, 6 Oct 2008 07:30:38 +0000 Subject: [PATCH] (bug 12586) Use wfHostname() everywhere, remove $wguname and $wgNodeName. Use getenv('COMPUTERNAME') on Windows. --- includes/GlobalFunctions.php | 3 +++ includes/Profiler.php | 5 ++--- includes/Setup.php | 6 ------ includes/db/Database.php | 4 ++-- includes/db/DatabaseMssql.php | 2 +- includes/db/LoadBalancer.php | 3 +-- includes/diff/DifferenceEngine.php | 4 ++-- 7 files changed, 11 insertions(+), 16 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 49d86a7757..6610738f6f 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -823,6 +823,9 @@ function wfHostname() { } if( is_array( $uname ) && isset( $uname['nodename'] ) ) { $host = $uname['nodename']; + } elseif ( getenv( 'COMPUTERNAME' ) ) { + # Windows computer name + $host = getenv( 'COMPUTERNAME' ); } else { # This may be a virtual server. $host = $_SERVER['SERVER_NAME']; diff --git a/includes/Profiler.php b/includes/Profiler.php index cef89dd355..ffb489780e 100644 --- a/includes/Profiler.php +++ b/includes/Profiler.php @@ -355,8 +355,7 @@ class Profiler { # Do not log anything if database is readonly (bug 5375) if( wfReadOnly() ) { return; } - # Warning: $wguname is a live patch, it should be moved to Setup.php - global $wguname, $wgProfilePerHost; + global $wgProfilePerHost; $dbw = wfGetDB( DB_MASTER ); if( !is_object( $dbw ) ) @@ -366,7 +365,7 @@ class Profiler { $name = substr($name, 0, 255); if( $wgProfilePerHost ){ - $pfhost = $wguname['nodename']; + $pfhost = wfHostname(); } else { $pfhost = ''; } diff --git a/includes/Setup.php b/includes/Setup.php index 8878d5df50..6f94c4f0ec 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -146,12 +146,6 @@ wfProfileIn( $fname.'-misc1' ); $wgIP = false; # Load on demand # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor $wgRequest = new WebRequest; -if ( function_exists( 'posix_uname' ) ) { - $wguname = posix_uname(); - $wgNodeName = $wguname['nodename']; -} else { - $wgNodeName = ''; -} # Useful debug output if ( $wgCommandLineMode ) { diff --git a/includes/db/Database.php b/includes/db/Database.php index bfd46bf78d..da85801def 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -312,7 +312,7 @@ class Database { * If the failFunction is set to a non-zero integer, returns success */ function open( $server, $user, $password, $dbName ) { - global $wguname, $wgAllDBsAreLocalhost; + global $wgAllDBsAreLocalhost; wfProfileIn( __METHOD__ ); # Test for missing mysql.so @@ -388,7 +388,7 @@ class Database { $success = @/**/mysql_select_db( $dbName, $this->mConn ); if ( !$success ) { $error = "Error selecting database $dbName on server {$this->mServer} " . - "from client host {$wguname['nodename']}\n"; + "from client host " . wfHostname() . "\n"; wfLogDBError(" Error selecting database $dbName on server {$this->mServer} \n"); wfDebug( $error ); } diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index da3b394616..5a02f5e99c 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -105,7 +105,7 @@ class DatabaseMssql extends Database { $success = @/**/mssql_select_db($dbName, $this->mConn); if (!$success) { $error = "Error selecting database $dbName on server {$this->mServer} " . - "from client host {$wguname['nodename']}\n"; + "from client host " . wfHostname() . "\n"; wfLogDBError(" Error selecting database $dbName on server {$this->mServer} \n"); wfDebug( $error ); } diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 6910ce90af..b44f067184 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -577,9 +577,8 @@ class LoadBalancer { $oldWiki = key( $this->mConns['foreignFree'][$i] ); if ( !$conn->selectDB( $dbName ) ) { - global $wguname; $this->mLastError = "Error selecting database $dbName on server " . - $conn->getServer() . " from client host {$wguname['nodename']}\n"; + $conn->getServer() . " from client host " . wfHostname() . "\n"; $this->mErrorConnection = $conn; $conn = false; } else { diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index 9697cd7a82..0176ae8659 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -642,10 +642,10 @@ CONTROL; * server node, and generator backend. */ protected function debug( $generator="internal" ) { - global $wgShowHostnames, $wgNodeName; + global $wgShowHostnames; $data = array( $generator ); if( $wgShowHostnames ) { - $data[] = $wgNodeName; + $data[] = wfHostname(); } $data[] = wfTimestamp( TS_DB ); return "