r69322 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69321‎ | r69322 | r69323 >
Date:01:18, 14 July 2010
Author:demon
Status:ok
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)
  • /trunk/phase3/includes/installer/LocalSettingsGenerator.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstaller.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -444,31 +444,14 @@
445445 'config-insecure-secretkey' => "'''Warning:''' Unable to create secure <code>\$wgSecretKey</code>.
446446 Consider changing it manually.",
447447 'config-install-sysop' => 'Creating administrator user account',
448 - 'config-install-localsettings' => 'Creating LocalSettings.php',
449 - 'config-install-localsettings-unwritable' => 'Warning: Could not write <code>LocalSettings.php</code>.
450 -Create it yourself, using the following text:
451 -<textarea name="LocalSettings" id="LocalSettings" cols="80" rows="25" readonly="readonly">
452 -$1
453 -</textarea>
454 -',
455448 'config-install-done' => "'''Congratulations!'''
456449 You have successfully installed MediaWiki.
457450
458451 We have generated a <code>LocalSettings.php</code> file for you. It contains all your configuration.
459452
460 -You will need to move it from <code>./config/LocalSettings.php</code> to <code>./LocalSettings.php</code> in order for MediaWiki to work:
 453+You will need to [$1 download] it and put it in the base of your wiki installation (the same directory as index.php)
461454
462 -On a Unix/Linux system:
463 -
464 -<pre>
465 -mv ./config/LocalSettings.php ./LocalSettings.php
466 -</pre>
467 -
468 -When that's done, you can [$1 '''enter your wiki''']",
469 - 'config-install-done-moved' => "'''Congratulations!'''
470 -You have successfully installed MediaWiki.
471 -
472 -[$1 Enter your wiki]",
 455+When that's done, you can [$2 '''enter your wiki''']", // $1 is the URL to LocalSettings download, $2 is link to wiki
473456 );
474457
475458 /** Dutch (Nederlands)
Index: trunk/phase3/includes/installer/WebInstaller.php
@@ -84,6 +84,17 @@
8585 $this->exportVars();
8686 $this->setupLanguage();
8787
 88+ if( $this->getVar( '_InstallDone' ) && $this->request->getVal( 'localsettings' ) )
 89+ {
 90+ $ls = new LocalSettingsGenerator( $this );
 91+ $this->request->response()->header('Content-type: text/plain');
 92+ $this->request->response()->header(
 93+ 'Content-Disposition: attachment; filename="LocalSettings.php"'
 94+ );
 95+ echo $ls->getText();
 96+ return $this->session;
 97+ }
 98+
8899 if ( isset( $session['happyPages'] ) ) {
89100 $this->happyPages = $session['happyPages'];
90101 } else {
@@ -1629,10 +1640,10 @@
16301641 public function execute() {
16311642 global $IP;
16321643 $this->startForm();
1633 - $msg = file_exists( "$IP/LocalSettings.php" ) ? 'config-install-done-moved' : 'config-install-done';
16341644 $this->addHTML(
16351645 $this->parent->getInfoBox(
1636 - wfMsgNoTrans( $msg,
 1646+ wfMsgNoTrans( 'config-install-done',
 1647+ $GLOBALS['wgServer'] . $this->parent->getURL( array( 'localsettings' => 1 ) ),
16371648 $GLOBALS['wgServer'] .
16381649 $this->getVar( 'wgScriptPath' ) . '/index' .
16391650 $this->getVar( 'wgScriptExtension' )
Index: trunk/phase3/includes/installer/Installer.php
@@ -133,7 +133,6 @@
134134 'interwiki',
135135 'secretkey',
136136 'sysop',
137 - 'localsettings',
138137 );
139138
140139 /**
@@ -890,7 +889,9 @@
891890 if( !$status->isOk() )
892891 break;
893892 }
894 - $this->setVar( '_InstallDone', true );
 893+ if( $status->isOk() ) {
 894+ $this->setVar( '_InstallDone', true );
 895+ }
895896 return $installResults;
896897 }
897898
@@ -973,11 +974,6 @@
974975 return Status::newGood();
975976 }
976977
977 - public function installLocalsettings() {
978 - $localSettings = new LocalSettingsGenerator( $this );
979 - return $localSettings->writeLocalSettings();
980 - }
981 -
982978 /**
983979 * Determine if LocalSettings exists. If it does, return an appropriate
984980 * status for whether we should can upgrade or not
Index: trunk/phase3/includes/installer/LocalSettingsGenerator.php
@@ -74,26 +74,6 @@
7575 return $localSettings;
7676 }
7777
78 - /**
79 - * Write the file
80 - * @param $secretKey String A random string to
81 - * @return boolean On successful file write
82 - */
83 - public function writeLocalSettings() {
84 - $localSettings = $this->getText();
85 - wfSuppressWarnings();
86 - $ret = file_put_contents( $this->configPath . '/LocalSettings.php', $localSettings );
87 - wfRestoreWarnings();
88 -
89 - $status = Status::newGood();
90 -
91 - if ( !$ret ) {
92 - $status->fatal( 'config-install-localsettings-unwritable', $localSettings );
93 - }
94 -
95 - return $status;
96 - }
97 -
9878 private function buildMemcachedServerList() {
9979 $servers = $this->values['_MemCachedServers'];
10080 if( !$servers ) {

Status & tagging log