From edd12f0fd60c740673c58919d10cf62e39b74442 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 14 Jul 2010 01:18:14 +0000 Subject: [PATCH] Installer no longer writes LocalSettings.php to /config. Now offer it as a download to the user and instruct them to upload/move it to the wiki base directory. Also only set _InstallDone if we hit no fatals during installation --- includes/installer/Installer.i18n.php | 21 ++----------------- includes/installer/Installer.php | 10 +++------ includes/installer/LocalSettingsGenerator.php | 20 ------------------ includes/installer/WebInstaller.php | 15 +++++++++++-- 4 files changed, 18 insertions(+), 48 deletions(-) diff --git a/includes/installer/Installer.i18n.php b/includes/installer/Installer.i18n.php index 45d1f9e403..a01f5afb7a 100644 --- a/includes/installer/Installer.i18n.php +++ b/includes/installer/Installer.i18n.php @@ -444,31 +444,14 @@ Make sure that the user "$1" can write to the schema "$2".', 'config-insecure-secretkey' => "'''Warning:''' Unable to create secure \$wgSecretKey. Consider changing it manually.", 'config-install-sysop' => 'Creating administrator user account', - 'config-install-localsettings' => 'Creating LocalSettings.php', - 'config-install-localsettings-unwritable' => 'Warning: Could not write LocalSettings.php. -Create it yourself, using the following text: - -', 'config-install-done' => "'''Congratulations!''' You have successfully installed MediaWiki. We have generated a LocalSettings.php file for you. It contains all your configuration. -You will need to move it from ./config/LocalSettings.php to ./LocalSettings.php in order for MediaWiki to work: - -On a Unix/Linux system: - -
-mv ./config/LocalSettings.php ./LocalSettings.php
-
- -When that's done, you can [$1 '''enter your wiki''']", - 'config-install-done-moved' => "'''Congratulations!''' -You have successfully installed MediaWiki. +You will need to [$1 download] it and put it in the base of your wiki installation (the same directory as index.php) -[$1 Enter your wiki]", +When that's done, you can [$2 '''enter your wiki''']", // $1 is the URL to LocalSettings download, $2 is link to wiki ); /** Dutch (Nederlands) diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 2d2eec33d6..5a725d4f5c 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -133,7 +133,6 @@ abstract class Installer { 'interwiki', 'secretkey', 'sysop', - 'localsettings', ); /** @@ -890,7 +889,9 @@ abstract class Installer { if( !$status->isOk() ) break; } - $this->setVar( '_InstallDone', true ); + if( $status->isOk() ) { + $this->setVar( '_InstallDone', true ); + } return $installResults; } @@ -973,11 +974,6 @@ abstract class Installer { return Status::newGood(); } - public function installLocalsettings() { - $localSettings = new LocalSettingsGenerator( $this ); - return $localSettings->writeLocalSettings(); - } - /** * Determine if LocalSettings exists. If it does, return an appropriate * status for whether we should can upgrade or not diff --git a/includes/installer/LocalSettingsGenerator.php b/includes/installer/LocalSettingsGenerator.php index 0a9266aeec..fc47f0f1da 100644 --- a/includes/installer/LocalSettingsGenerator.php +++ b/includes/installer/LocalSettingsGenerator.php @@ -74,26 +74,6 @@ class LocalSettingsGenerator { return $localSettings; } - /** - * Write the file - * @param $secretKey String A random string to - * @return boolean On successful file write - */ - public function writeLocalSettings() { - $localSettings = $this->getText(); - wfSuppressWarnings(); - $ret = file_put_contents( $this->configPath . '/LocalSettings.php', $localSettings ); - wfRestoreWarnings(); - - $status = Status::newGood(); - - if ( !$ret ) { - $status->fatal( 'config-install-localsettings-unwritable', $localSettings ); - } - - return $status; - } - private function buildMemcachedServerList() { $servers = $this->values['_MemCachedServers']; if( !$servers ) { diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index 21eccd0014..e009ad5178 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -84,6 +84,17 @@ class WebInstaller extends Installer { $this->exportVars(); $this->setupLanguage(); + if( $this->getVar( '_InstallDone' ) && $this->request->getVal( 'localsettings' ) ) + { + $ls = new LocalSettingsGenerator( $this ); + $this->request->response()->header('Content-type: text/plain'); + $this->request->response()->header( + 'Content-Disposition: attachment; filename="LocalSettings.php"' + ); + echo $ls->getText(); + return $this->session; + } + if ( isset( $session['happyPages'] ) ) { $this->happyPages = $session['happyPages']; } else { @@ -1629,10 +1640,10 @@ class WebInstaller_Complete extends WebInstallerPage { public function execute() { global $IP; $this->startForm(); - $msg = file_exists( "$IP/LocalSettings.php" ) ? 'config-install-done-moved' : 'config-install-done'; $this->addHTML( $this->parent->getInfoBox( - wfMsgNoTrans( $msg, + wfMsgNoTrans( 'config-install-done', + $GLOBALS['wgServer'] . $this->parent->getURL( array( 'localsettings' => 1 ) ), $GLOBALS['wgServer'] . $this->getVar( 'wgScriptPath' ) . '/index' . $this->getVar( 'wgScriptExtension' ) -- 2.20.1