On 15/06/06, Brion Vibber <brion(a)pobox.com> wrote:
Ben Bullock wrote:
I know I'm not supposed to edit
DefaultSettings.php, so what should I do?
Edit LocalSettings.php.
OK, I have tried that, but perhaps I missed something, so I tried
editing it like this:
$wgServerName = $_SERVER['HTTP_HOST'];
require_once( "includes/DefaultSettings.php" );
$wgServerName = $_SERVER['HTTP_HOST'];
(this is cut and paste from LocalSettings.php)
Unfortunately even though I bloodymindedly set $wgServerName to the
correct string both before and after the require, it's still being
ignored, and the server name in the address bar is being set to the
wrong name. If I twist the order of the if statements in
DefaultSettings.php, however, like this:
if( isset( $_SERVER['HTTP_HOST'] ) ) {
$wgServerName = $_SERVER['HTTP_HOST'];
} elseif( isset( $_SERVER['SERVER_NAME'] ) ) {
$wgServerName = $_SERVER['SERVER_NAME'];
} elseif( isset( $_SERVER['HOSTNAME'] ) ) {
$wgServerName = $_SERVER['HOSTNAME'];
} elseif( isset( $_SERVER['SERVER_ADDR'] ) ) {
$wgServerName = $_SERVER['SERVER_ADDR'];
} else {
$wgServerName = 'localhost';
}
(again this is cut and paste) it works. I'd like to follow your advice
about not editing DefaultSettings.php, but I don't see what edit in
LocalSettings.php to make to make the address display correctly.
Let's have a look at the code of DefaultSettings.php:
$wgServer = $wgProto.'://' . $wgServerName;
# If the port is a non-standard one, add it to the URL
if( isset( $_SERVER['SERVER_PORT'] )
&& ( ( $wgProto == 'http' &&
$_SERVER['SERVER_PORT'] != 80 )
|| ( $wgProto == 'https' && $_SERVER['SERVER_PORT'] !=
443 ) ) ) {
$wgServer .= ":" . $_SERVER['SERVER_PORT'];
}
$wgEmergencyContact = 'wikiadmin@' . $wgServerName;
$wgPasswordSender = 'MediaWiki Mail <apache@' . $wgServerName .
'>';
$wgInternalServer = $wgServer;
All of these, plus maybe some things I didn't notice, make use of
$wgServerName. That looks to me like I'm screwed. There is no way for
me to adjust what MediaWiki thinks the server's name is after it sets
it in the if statements and before it jumps into the above code and
sets lots of variables using its own value. So editing
LocalSettings.php isn't going to do much good unless I duplicate *all*
of the above $wgServerName related code in LocalSettings.php, with
consequent high chances of bugs etc. In my case at least, it makes
much more sense to me to edit DefaultSettings.php.