r64348 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64347‎ | r64348 | r64349 >
Date:16:28, 29 March 2010
Author:maxsem
Status:ok (Comments)
Tags:
Comment:
Install step: separated failures from non-fatals, made it offer to create LocalSettings manually if the installer couldn't do it itself
Modified paths:
  • /branches/new-installer/phase3/includes/installer/Installer.php (modified) (history)
  • /branches/new-installer/phase3/includes/installer/LocalSettings.php (modified) (history)
  • /branches/new-installer/phase3/includes/installer/WebInstaller.php (modified) (history)
  • /branches/new-installer/phase3/includes/installer/WebInstallerOutput.php (modified) (history)
  • /branches/new-installer/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /branches/new-installer/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: branches/new-installer/phase3/maintenance/language/messages.inc
@@ -3361,8 +3361,10 @@
33623362 'config-install-tables',
33633363 'config-install-interwiki-sql',
33643364 'config-install-secretkey',
 3365+ 'config-insecure-secretkey',
33653366 'config-install-sysop',
33663367 'config-install-localsettings',
 3368+ 'config-install-localsettings-unwritable',
33673369 'config-install-done',
33683370 'config-install-done-moved',
33693371 ),
Index: branches/new-installer/phase3/includes/installer/LocalSettings.php
@@ -4,12 +4,14 @@
55 private $extensions, $values = array();
66 private $configPath, $dbSettings = '';
77 private $safeMode = false;
 8+ private $installer;
89
910 /**
1011 * Construtor.
1112 * @param $installer Installer subclass
1213 */
1314 public function __construct( Installer $installer ) {
 15+ $this->installer = $installer;
1416 $this->configPath = $installer->getVar( 'IP' ) . '/config';
1517 $this->extensions = $installer->getVar( '_Extensions' );
1618 $db = $installer->getDBInstaller( $installer->getVar( 'wgDBtype' ) );
@@ -65,7 +67,16 @@
6668 $localSettings .= "require( 'extensions/$ext/$ext.php' );\n";
6769 }
6870 }
69 - return file_put_contents( $this->configPath . '/LocalSettings.php', $localSettings );
 71+ wfSuppressWarnings();
 72+ $ret = file_put_contents( $this->configPath . '/LocalSettings.php', $localSettings );
 73+ wfRestoreWarnings();
 74+ if ( !$ret ) {
 75+ $warn = wfMsg( 'config-install-localsettings-unwritable' ) . '
 76+<textarea name="LocalSettings" id="LocalSettings" cols="80" rows="25" readonly="readonly">'
 77+ . htmlspecialchars( $localSettings ) . '</textarea>';
 78+ $this->installer->output->addWarning( $warn );
 79+ }
 80+ return $ret;
7081 }
7182
7283 private function buildMemcachedServerList() {
Index: branches/new-installer/phase3/includes/installer/WebInstaller.php
@@ -765,6 +765,7 @@
766766 }
767767
768768 function endForm( $continue = 'continue' ) {
 769+ $this->parent->output->outputWarnings();
769770 $s = "<div class=\"config-submit\">\n";
770771 $id = $this->getId();
771772 if ( $id === false ) {
Index: branches/new-installer/phase3/includes/installer/WebInstallerOutput.php
@@ -11,6 +11,7 @@
1212 class WebInstallerOutput {
1313 var $parent;
1414 var $contents = '';
 15+ var $warnings = '';
1516 var $headerDone = false;
1617 var $redirectTarget;
1718 var $debug = true;
@@ -33,6 +34,16 @@
3435 $this->contents .= $html;
3536 }
3637
 38+ function addWarning( $msg ) {
 39+ $this->warnings .= "<p>$msg</p>\n";
 40+ }
 41+
 42+ function addWarningMsg( $msg /*, ... */ ) {
 43+ $params = func_get_args();
 44+ array_shift( $params );
 45+ $this->addWarning( wfMsg( $msg, $params ) );
 46+ }
 47+
3748 function redirect( $url ) {
3849 if ( $this->headerDone ) {
3950 throw new MWException( __METHOD__ . ' called after sending headers' );
@@ -122,6 +133,8 @@
123134 }
124135
125136 function outputFooter() {
 137+ $this->outputWarnings();
 138+
126139 if ( $this->useShortHeader ) {
127140 ?>
128141 </body></html>
@@ -170,4 +183,9 @@
171184 <body style="background-image: none">
172185 <?php
173186 }
 187+
 188+ function outputWarnings() {
 189+ $this->addHTML( $this->warnings );
 190+ $this->warnings = '';
 191+ }
174192 }
Index: branches/new-installer/phase3/includes/installer/Installer.php
@@ -806,16 +806,15 @@
807807 if ( $file ) {
808808 $secretKey = bin2hex( fread( $file, 32 ) );
809809 fclose( $file );
810 - $ret = true;
811810 } else {
812811 $secretKey = "";
813812 for ( $i=0; $i<8; $i++ ) {
814813 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
815814 }
816 - $ret = false;
 815+ $this->output->addWarningMsg( 'config-insecure-secretkey' );
817816 }
818817 $this->setVar( 'wgSecretKey', $secretKey );
819 - return $ret;
 818+ return true;
820819 }
821820
822821 public function installSysop() {
Index: branches/new-installer/phase3/languages/messages/MessagesEn.php
@@ -4586,8 +4586,10 @@
45874587 'config-install-tables' => 'Creating tables',
45884588 'config-install-interwiki-sql' => 'Could not find file interwiki.sql',
45894589 'config-install-secretkey' => 'Generating secret key',
 4590+'config-insecure-secretkey' => 'Warning: Unable to create secure $wgSecretKey. Consider changing it manually.',
45904591 'config-install-sysop' => 'Creating administrator user account',
4591 -'config-install-localsettings' => 'Writing LocalSettings.php',
 4592+'config-install-localsettings' => 'Creating LocalSettings.php',
 4593+'config-install-localsettings-unwritable' => 'Warning: could not write LocalSettings.php. Please create it yourself, using the following text:',
45924594 'config-install-done' => "'''Congratulations''', you have successfully installed MediaWiki.
45934595
45944596 You will need to move it from <tt>./config/LocalSettings.php</tt> to <tt>./LocalSettings.php</tt> in order

Comments

#Comment by 😂 (talk | contribs)   16:02, 3 April 2010

This is fine for now. Ideally I'd like to return Status objects so we can clearly separate OK/Warning/Fatal.

Status & tagging log