* 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.
This commit is contained in:
Mark A. Hershberger 2010-07-02 21:15:13 +00:00
parent 3136686db6
commit c4100fb83b
5 changed files with 26 additions and 28 deletions

View file

@ -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',

View file

@ -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() );
}
}

View file

@ -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() {

View file

@ -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() {

View file

@ -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(
"<div class=\"config-message\">\n" .