(bug 12586) Use wfHostname() everywhere, remove $wguname and $wgNodeName. Use getenv...
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 6 Oct 2008 07:30:38 +0000 (07:30 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 6 Oct 2008 07:30:38 +0000 (07:30 +0000)
includes/GlobalFunctions.php
includes/Profiler.php
includes/Setup.php
includes/db/Database.php
includes/db/DatabaseMssql.php
includes/db/LoadBalancer.php
includes/diff/DifferenceEngine.php

index 49d86a7..6610738 100644 (file)
@@ -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'];
index cef89dd..ffb4897 100644 (file)
@@ -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 = '';
                }
index 8878d5d..6f94c4f 100644 (file)
@@ -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 ) {
index bfd46bf..da85801 100644 (file)
@@ -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 );
                        }
index da3b394..5a02f5e 100644 (file)
@@ -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 );
                                }
index 6910ce9..b44f067 100644 (file)
@@ -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 {
index 9697cd7..0176ae8 100644 (file)
@@ -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 "<!-- diff generator: " .