r68698 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68697‎ | r68698 | r68699 >
Date:02:46, 29 June 2010
Author:mah
Status:ok
Tags:
Comment:
* remove bogus outputFooter call
* strip tags + de-code entities before outputing messages to CLI (need an un-wiki call)
* Make LocalSettings::writeLocalSettings return a Status object instead of true/false so we can use the text in out cli output.
Modified paths:
  • /trunk/phase3/includes/installer/CliInstallerOutput.php (modified) (history)
  • /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)

Diff [purge]

Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -430,7 +430,11 @@
431431 'config-install-sysop' => 'Creating administrator user account',
432432 'config-install-localsettings' => 'Creating LocalSettings.php',
433433 'config-install-localsettings-unwritable' => 'Warning: Could not write <code>LocalSettings.php</code>.
434 -Create it yourself, using the following text:',
 434+Create it yourself, using the following text:
 435+<textarea name="LocalSettings" id="LocalSettings" cols="80" rows="25" readonly="readonly">
 436+$1
 437+</textarea>
 438+',
435439 'config-install-done' => "'''Congratulations!'''
436440 You have successfully installed MediaWiki.
437441
Index: trunk/phase3/includes/installer/Installer.php
@@ -908,15 +908,7 @@
909909
910910 public function installLocalsettings() {
911911 $localSettings = new LocalSettingsGenerator( $this );
912 - $ok = $localSettings->writeLocalSettings();
913 -
914 - # TODO: Make writeLocalSettings() itself not warn, but instead return
915 - # a Status object to us to pass along.
916 - if ( $ok ) {
917 - return Status::newGood();
918 - } else {
919 - return Status::newFatal();
920 - }
 912+ return $localSettings->writeLocalSettings();
921913 }
922914
923915 /**
Index: trunk/phase3/includes/installer/LocalSettingsGenerator.php
@@ -15,7 +15,7 @@
1616 $this->configPath = $installer->getVar( 'IP' ) . '/config';
1717 $this->extensions = $installer->getVar( '_Extensions' );
1818 $db = $installer->getDBInstaller( $installer->getVar( 'wgDBtype' ) );
19 -
 19+
2020 $confItems = array_merge( array( 'wgScriptPath', 'wgScriptExtension',
2121 'wgPasswordSender', 'wgImageMagickConvertCommand', 'wgShellLocale',
2222 'wgLanguageCode', 'wgEnableEmail', 'wgEnableUserEmail', 'wgDiff3',
@@ -58,11 +58,11 @@
5959 }
6060
6161 /**
62 - * Write the file
63 - * @param $secretKey String A random string to
64 - * @return boolean On successful file write
 62+ * Return the full text of the generated LocalSettings.php file,
 63+ * including the extensions
 64+ * @returns String
6565 */
66 - public function writeLocalSettings() {
 66+ public function getText() {
6767 $localSettings = $this->getDefaultText();
6868 if( count( $this->extensions ) ) {
6969 $localSettings .= "\n# The following extensions were automatically enabled:\n";
@@ -70,18 +70,30 @@
7171 $localSettings .= "require( 'extensions/$ext/$ext.php' );\n";
7272 }
7373 }
 74+
 75+ return $localSettings;
 76+ }
 77+
 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();
7485 wfSuppressWarnings();
7586 $ret = file_put_contents( $this->configPath . '/LocalSettings.php', $localSettings );
7687 wfRestoreWarnings();
 88+
 89+ $status = Status::newGood();
 90+
7791 if ( !$ret ) {
78 - $warn = wfMsg( 'config-install-localsettings-unwritable' ) . '
79 -<textarea name="LocalSettings" id="LocalSettings" cols="80" rows="25" readonly="readonly">'
80 - . htmlspecialchars( $localSettings ) . '</textarea>';
81 - $this->installer->output->addWarning( $warn );
 92+ $status->fatal( 'config-install-localsettings-unwritable', $localSettings );
8293 }
83 - return $ret;
 94+
 95+ return $status;
8496 }
85 -
 97+
8698 private function buildMemcachedServerList() {
8799 $servers = $this->values['_MemCachedServers'];
88100 if( !$servers ) {
Index: trunk/phase3/includes/installer/CliInstallerOutput.php
@@ -45,14 +45,13 @@
4646
4747 function output() {
4848 $this->flush();
49 - $this->outputFooter();
5049 }
5150
5251 function useShortHeader( $use = true ) {
5352 }
5453
5554 function flush() {
56 - echo $this->contents;
 55+ echo html_entity_decode( strip_tags( $this->contents ), ENT_QUOTES );
5756 flush();
5857 $this->contents = '';
5958 }
@@ -77,7 +76,4 @@
7877 $this->addHTML( $this->warnings );
7978 $this->warnings = '';
8079 }
81 -
82 - function outputFooter() {}
83 -
8480 }

Status & tagging log