Page MenuHomePhabricator

nodename.patch

Authored By
bzimport
Nov 21 2014, 10:05 PM
Size
3 KB
Referenced Files
None
Subscribers
None

nodename.patch

Index: includes/GlobalFunctions.php
===================================================================
--- includes/GlobalFunctions.php (revision 29694)
+++ includes/GlobalFunctions.php (working copy)
@@ -673,35 +673,25 @@
* @return string
*/
function wfHostname() {
- if ( function_exists( 'posix_uname' ) ) {
- // This function not present on Windows
- $uname = @posix_uname();
- } else {
- $uname = false;
- }
- if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
- return $uname['nodename'];
- } else {
- # This may be a virtual server.
- return $_SERVER['SERVER_NAME'];
- }
+ global $wgNodeName;
+ return $wgNodeName;
}
- /**
- * Returns a HTML comment with the elapsed time since request.
- * This method has no side effects.
- * @return string
- */
- function wfReportTime() {
- global $wgRequestTime, $wgShowHostnames;
+/**
+ * Returns a HTML comment with the elapsed time since request.
+ * This method has no side effects.
+ * @return string
+ */
+function wfReportTime() {
+ global $wgRequestTime, $wgShowHostnames, $wgNodeName;
- $now = wfTime();
- $elapsed = $now - $wgRequestTime;
+ $now = wfTime();
+ $elapsed = $now - $wgRequestTime;
- return $wgShowHostnames
- ? sprintf( "<!-- Served by %s in %01.3f secs. -->", wfHostname(), $elapsed )
- : sprintf( "<!-- Served in %01.3f secs. -->", $elapsed );
- }
+ return $wgShowHostnames
+ ? sprintf( "<!-- Served by %s in %01.3f secs. -->", $wgNodeName, $elapsed )
+ : sprintf( "<!-- Served in %01.3f secs. -->", $elapsed );
+}
/**
* Safety wrapper for debug_backtrace().
Index: includes/Setup.php
===================================================================
--- includes/Setup.php (revision 29694)
+++ includes/Setup.php (working copy)
@@ -137,12 +137,26 @@
$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' ) ) {
+ // This function is not present on Windows
$wguname = posix_uname();
- $wgNodeName = $wguname['nodename'];
} else {
- $wgNodeName = '';
+ $wguname = array();
}
+if( is_array( $wguname ) && isset( $wguname['nodename'] ) ) {
+ $wgNodeName = $wguname['nodename'];
+} else{
+ $uname = php_uname( 'n' );
+ if( !empty( $uname ) ){
+ $wgNodeName = $uname;
+ } else if( isset( $_SERVER['SERVER_NAME'] ) ) {
+ # This may be a virtual server.
+ $wgNodeName = $_SERVER['SERVER_NAME'];
+ } else {
+ $wgNodeName = '';
+ }
+}
# Useful debug output
if ( $wgCommandLineMode ) {
Index: includes/Profiler.php
===================================================================
--- includes/Profiler.php (revision 29694)
+++ includes/Profiler.php (working copy)
@@ -304,8 +304,7 @@
# 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 $wgNodeName, $wgProfilePerHost;
$fname = 'Profiler::logToDB';
$dbw = wfGetDB(DB_MASTER);
@@ -318,7 +317,7 @@
$encname = $dbw->strencode($name);
if ($wgProfilePerHost) {
- $pfhost = $wguname['nodename'];
+ $pfhost = $wgNodeName;
} else {
$pfhost = '';
}
Index: includes/Database.php
===================================================================
--- includes/Database.php (revision 29694)
+++ includes/Database.php (working copy)
@@ -574,7 +574,7 @@
* If the failFunction is set to a non-zero integer, returns success
*/
function open( $server, $user, $password, $dbName ) {
- global $wguname;
+ global $wgNodeName;
wfProfileIn( __METHOD__ );
# Test for missing mysql.so
@@ -625,7 +625,7 @@
$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 {$wgNodeName}\n";
wfLogDBError(" Error selecting database $dbName on server {$this->mServer} \n");
wfDebug( $error );
}

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4268
Default Alt Text
nodename.patch (3 KB)

Event Timeline