Do not set wgServer in cli install unless explicitly passed

Currently, if we do not pass a wgServer value (via --server),
the CLI installer sets the value to the default value
specified in DefaultSettings.php - which is to 'guess' by
calling into WebRequest::detectServer. This yields terrible
results, since WebRequest::detectServer expects to be working
in the context of a Web Request - and hence with HTTP Host
header information. Since calling from the CLI does not give
it host header information, it falls back to 'localhost',
which is not the value you usually want.

If we just do not set wgServer when it is not specified,
it is automatically calculated on every request by
WebRequest::detectServer, which does a splendid job.

Bug: 55376
Change-Id: I5436dd8c340604cbb59406a507188e11c8f86e86
This commit is contained in:
YuviPanda 2013-10-07 01:11:18 +05:30
parent 7d1cd6c376
commit 513a7198e8
3 changed files with 13 additions and 10 deletions

View file

@ -203,7 +203,7 @@ class CliInstaller extends Installer {
}
protected function envGetDefaultServer() {
return $this->getVar( 'wgServer' );
return null; // Do not guess if installing from CLI
}
public function dirIsExecutable( $dir, $url ) {

View file

@ -158,7 +158,6 @@ abstract class Installer {
'wgImageMagickConvertCommand',
'wgGitBin',
'IP',
'wgServer',
'wgScriptPath',
'wgScriptExtension',
'wgMetaNamespace',
@ -980,9 +979,10 @@ abstract class Installer {
*/
protected function envCheckServer() {
$server = $this->envGetDefaultServer();
$this->showMessage( 'config-using-server', $server );
$this->setVar( 'wgServer', $server );
if ( $server !== null ) {
$this->showMessage( 'config-using-server', $server );
$this->setVar( 'wgServer', $server );
}
return true;
}

View file

@ -80,7 +80,7 @@ class LocalSettingsGenerator {
$val = wfBoolToStr( $val );
}
if ( !in_array( $c, $unescaped ) ) {
if ( !in_array( $c, $unescaped ) && $val !== null ) {
$val = self::escapePhpString( $val );
}
@ -222,6 +222,12 @@ class LocalSettingsGenerator {
}
}
$wgServerSetting = "";
if ( array_key_exists( 'wgServer', $this->values ) && $this->values['wgServer'] !== null ) {
$wgServerSetting = "\n## The protocol and server name to use in fully-qualified URLs\n";
$wgServerSetting .= "\$wgServer = \"{$this->values['wgServer']}\";\n";
}
switch ( $this->values['wgMainCacheType'] ) {
case 'anything':
case 'db':
@ -265,10 +271,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
## http://www.mediawiki.org/wiki/Manual:Short_URL
\$wgScriptPath = \"{$this->values['wgScriptPath']}\";
\$wgScriptExtension = \"{$this->values['wgScriptExtension']}\";
## The protocol and server name to use in fully-qualified URLs
\$wgServer = \"{$this->values['wgServer']}\";
${wgServerSetting}
## The relative URL path to the skins directory
\$wgStylePath = \"\$wgScriptPath/skins\";