Page MenuHomePhabricator

Wrong redirects if $wgServerName not set.
Closed, ResolvedPublic

Description

Author: bothie

Description:
In non-public environments, servername may be localhost or something like that. If
I now try to set up mediawiki, I get redirected to localhost in some cases, which
is bad[TM]. Current implementation tries to guess $wgServerName by looking at
SERVER_NAME and HOSTNAME and falls back to 'localhost' if either fails. The
env-vars may each be set to localhost, which is wrong, if I use any other system to
access the wiki. HTTP_HOST contains the domain or ip address used in the uri when a
page is requested. So try first to obtain $wgServerName form there, and only fall
back to any of the other ways if that fails.

Regards, Bodo.

The patch is also available for download at
http://bothie.sharedaemon.org/temp/mediawiki-1.3.8-bt1.diff - just for the case of
problems with tabs etc.

diff -ur mediawiki-1.3.8/includes/DefaultSettings.php
mediawiki/includes/DefaultSettings.php

  • mediawiki-1.3.8/includes/DefaultSettings.php 2004-11-16

00:59:13.000000000 +0100
+++ mediawiki/includes/DefaultSettings.php 2004-12-12 00:18:17.000000000 +0100
@@ -14,8 +14,11 @@
$wgSitename = 'MediaWiki'; # Please customize!
$wgMetaNamespace = FALSE; # will be same as you set $wgSitename

-if( isset( $_SERVER['SERVER_NAME'] ) ) {
+if (isset( $_SERVER["HTTP_HOST"] )) {
+ # First try to get the ServerName from the only point, which is
+ # correct in ANY case. Only if that faily, try other guesses.
+ $wgServerName = $_SERVER["HTTP_HOST"];
+} elseif( isset( $_SERVER['SERVER_NAME'] ) ) {

$wgServerName = $_SERVER['SERVER_NAME'];

} elseif( isset( $_SERVER['HOSTNAME'] ) ) {

$wgServerName = $_SERVER['HOSTNAME'];

Version: 1.3.x
Severity: enhancement

Details

Reference
bz1077

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:01 PM
bzimport set Reference to bz1077.
bzimport added a subscriber: Unknown Object (MLST).
  • This bug has been marked as a duplicate of 61 ***