From 04b06273c450bde4c01daa0f2596dd0272803e68 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Tue, 29 Jun 2010 02:46:11 +0000 Subject: [PATCH] * 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. --- includes/installer/CliInstallerOutput.php | 6 +--- includes/installer/Installer.i18n.php | 6 +++- includes/installer/Installer.php | 10 +----- includes/installer/LocalSettingsGenerator.php | 34 +++++++++++++------ 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/includes/installer/CliInstallerOutput.php b/includes/installer/CliInstallerOutput.php index 55c239cdc2..40cfe03185 100644 --- a/includes/installer/CliInstallerOutput.php +++ b/includes/installer/CliInstallerOutput.php @@ -45,14 +45,13 @@ class CliInstallerOutput { function output() { $this->flush(); - $this->outputFooter(); } function useShortHeader( $use = true ) { } function flush() { - echo $this->contents; + echo html_entity_decode( strip_tags( $this->contents ), ENT_QUOTES ); flush(); $this->contents = ''; } @@ -77,7 +76,4 @@ class CliInstallerOutput { $this->addHTML( $this->warnings ); $this->warnings = ''; } - - function outputFooter() {} - } diff --git a/includes/installer/Installer.i18n.php b/includes/installer/Installer.i18n.php index 4ea47d85e9..d624532395 100644 --- a/includes/installer/Installer.i18n.php +++ b/includes/installer/Installer.i18n.php @@ -430,7 +430,11 @@ 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:', +Create it yourself, using the following text: + +', 'config-install-done' => "'''Congratulations!''' You have successfully installed MediaWiki. diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 38ecde17ce..613c304051 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -908,15 +908,7 @@ abstract class Installer { public function installLocalsettings() { $localSettings = new LocalSettingsGenerator( $this ); - $ok = $localSettings->writeLocalSettings(); - - # TODO: Make writeLocalSettings() itself not warn, but instead return - # a Status object to us to pass along. - if ( $ok ) { - return Status::newGood(); - } else { - return Status::newFatal(); - } + return $localSettings->writeLocalSettings(); } /** diff --git a/includes/installer/LocalSettingsGenerator.php b/includes/installer/LocalSettingsGenerator.php index ce41160304..aae9aadb43 100644 --- a/includes/installer/LocalSettingsGenerator.php +++ b/includes/installer/LocalSettingsGenerator.php @@ -15,7 +15,7 @@ class LocalSettingsGenerator { $this->configPath = $installer->getVar( 'IP' ) . '/config'; $this->extensions = $installer->getVar( '_Extensions' ); $db = $installer->getDBInstaller( $installer->getVar( 'wgDBtype' ) ); - + $confItems = array_merge( array( 'wgScriptPath', 'wgScriptExtension', 'wgPasswordSender', 'wgImageMagickConvertCommand', 'wgShellLocale', 'wgLanguageCode', 'wgEnableEmail', 'wgEnableUserEmail', 'wgDiff3', @@ -58,11 +58,11 @@ class LocalSettingsGenerator { } /** - * Write the file - * @param $secretKey String A random string to - * @return boolean On successful file write + * Return the full text of the generated LocalSettings.php file, + * including the extensions + * @returns String */ - public function writeLocalSettings() { + public function getText() { $localSettings = $this->getDefaultText(); if( count( $this->extensions ) ) { $localSettings .= "\n# The following extensions were automatically enabled:\n"; @@ -70,18 +70,30 @@ class LocalSettingsGenerator { $localSettings .= "require( 'extensions/$ext/$ext.php' );\n"; } } + + 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 ) { - $warn = wfMsg( 'config-install-localsettings-unwritable' ) . ' -'; - $this->installer->output->addWarning( $warn ); + $status->fatal( 'config-install-localsettings-unwritable', $localSettings ); } - return $ret; + + return $status; } - + private function buildMemcachedServerList() { $servers = $this->values['_MemCachedServers']; if( !$servers ) { -- 2.20.1