From c4100fb83b5b12bdb790bccd86f1cb32a56bd2f1 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Fri, 2 Jul 2010 21:15:13 +0000 Subject: [PATCH] * Eliminate CLIInstallerOutput per r68645 since, yes, it wasn't needed. * Make sure output only happens in the top-level Installer implementations. * Differentiate Status warning messages from Status error messages in the Installer. * Change abstract method from Install::showStatusError() to Install::showStatusMessage() since we'll use it to show warnings now, too. * TODO Need a better way to extract/display Status warning messages since, from my look at the Status class, it looks like warnings are implemented, but not really used. --- includes/AutoLoader.php | 1 - includes/installer/CliInstaller.php | 19 +++++++++---------- includes/installer/Installer.php | 12 ++++++++---- includes/installer/SqliteInstaller.php | 20 ++++++++------------ includes/installer/WebInstaller.php | 2 +- 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 6571c9e8dd..b4ae511b80 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -414,7 +414,6 @@ $wgAutoloadLocalClasses = array( # includes/installer 'CliInstaller' => 'includes/installer/CliInstaller.php', - 'CliInstallerOutput' => 'includes/installer/CliInstallerOutput.php', 'Installer' => 'includes/installer/Installer.php', 'InstallerDBType' => 'includes/installer/InstallerDBType.php', 'LBFactory_InstallerFake' => 'includes/installer/Installer.php', diff --git a/includes/installer/CliInstaller.php b/includes/installer/CliInstaller.php index 2e1ecd1e6a..9952f4616d 100644 --- a/includes/installer/CliInstaller.php +++ b/includes/installer/CliInstaller.php @@ -62,8 +62,6 @@ class CliInstaller extends Installer { if ( isset( $option['pass'] ) ) { $this->setVar( '_AdminPassword', $option['pass'] ); } - - $this->output = new CliInstallerOutput( $this ); } /** @@ -74,22 +72,23 @@ class CliInstaller extends Installer { $this->showMessage("Installing $step... "); $func = 'install' . ucfirst( $step ); $status = $this->{$func}(); - $ok = $status->isGood(); - if ( !$ok ) { - $this->showStatusError( $status ); + if ( !$status->isOk() ) { + $this->showStatusMessage( $status ); exit; + } elseif ( !$status->isGood() ) { + $this->showStatusMessage( $status ); } $this->showMessage("done\n"); } } function showMessage( $msg /*, ... */ ) { - $this->output->addHTML($msg); - $this->output->output(); + echo html_entity_decode( strip_tags( $msg ), ENT_QUOTES ); + flush(); } - function showStatusError( $status ) { - $this->output->addHTML($status->getWikiText()."\n"); - $this->output->flush(); + function showStatusMessage( $status ) { + $this->showMessage( $status->getWikiText() ); } + } diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 8a3ab4ef11..03804423f1 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -260,7 +260,7 @@ abstract class Installer { */ abstract function showMessage( $msg /*, ... */ ); - abstract function showStatusError( $status ); + abstract function showStatusMessage( $status ); /** * Get a list of known DB types @@ -869,7 +869,7 @@ abstract class Installer { public function installTables() { $installer = $this->getDBInstaller(); $status = $installer->createTables(); - if( $status->isGood() ) { + if( $status->isOK() ) { LBFactory::enableBackend(); } return $status; @@ -888,6 +888,9 @@ abstract class Installer { $file = fopen( "/dev/urandom", "r" ); wfRestoreWarnings(); } + + $status = Status::newGood(); + if ( $file ) { $secretKey = bin2hex( fread( $file, 32 ) ); fclose( $file ); @@ -896,10 +899,11 @@ abstract class Installer { for ( $i=0; $i<8; $i++ ) { $secretKey .= dechex(mt_rand(0, 0x7fffffff)); } - $this->output->addWarningMsg( 'config-insecure-secretkey' ); + $status->warning( 'config-insecure-secretkey' ); } $this->setVar( 'wgSecretKey', $secretKey ); - return Status::newGood(); + + return $status; } public function installSysop() { diff --git a/includes/installer/SqliteInstaller.php b/includes/installer/SqliteInstaller.php index c6ac2018f0..1f7790678d 100644 --- a/includes/installer/SqliteInstaller.php +++ b/includes/installer/SqliteInstaller.php @@ -158,31 +158,27 @@ class SqliteInstaller extends InstallerDBType { //@todo or...? $this->db->reportQueryError( $err, 0, $sql, __FUNCTION__ ); } - $this->setupSearchIndex(); - // Create default interwikis - return Status::newGood(); + return $this->setupSearchIndex(); } function setupSearchIndex() { global $IP; + $status = Status::newGood(); + $module = $this->db->getFulltextSearchModule(); $fts3tTable = $this->db->checkForEnabledSearch(); if ( $fts3tTable && !$module ) { - $this->parent->output->addHtml - ( wfMsgHtml( 'word-separator' ) . wfMsgHtml( 'config-sqlite-fts3-downgrade' ) . wfMsgHtml( 'ellipsis' ) ); - $this->parent->output->flush(); + $status->warning( 'config-sqlite-fts3-downgrade' ); $this->db->sourceFile( "$IP/maintenance/sqlite/archives/searchindex-no-fts.sql" ); } elseif ( !$fts3tTable && $module == 'FTS3' ) { - $this->parent->output->addHtml - ( wfMsgHtml( 'word-separator' ) . wfMsgHtml( 'config-sqlite-fts3-add' ) . wfMsg( 'ellipsis' ) ); - $this->parent->output->flush(); + $status->warning( 'config-sqlite-fts3-add' ); $this->db->sourceFile( "$IP/maintenance/sqlite/archives/searchindex-fts3.sql" ); } else { - $this->parent->output->addHtml - ( wfMsgHtml( 'word-separator' ) . wfMsgHtml( 'config-sqlite-fts3-ok' ) . wfMsgHtml( 'ellipsis' ) ); - $this->parent->output->flush(); + $status->warning( 'config-sqlite-fts3-ok' ); } + + return $status; } function doUpgrade() { diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index 5b17d0b5a0..f5ada78ba8 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -739,7 +739,7 @@ class WebInstaller extends Installer { $this->output->addHTML( $this->getErrorBox( $text ) ); } - function showStatusError( $status ) { + function showStatusMessage( $status ) { $text = $status->getWikiText(); $this->output->addWikiText( "
\n" . -- 2.20.1