r68908 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68907‎ | r68908 | r68909 >
Date:21:15, 2 July 2010
Author:mah
Status:ok (Comments)
Tags:
Comment:
* 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.
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/installer/CliInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)
  • /trunk/phase3/includes/installer/SqliteInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstaller.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/WebInstaller.php
@@ -739,7 +739,7 @@
740740 $this->output->addHTML( $this->getErrorBox( $text ) );
741741 }
742742
743 - function showStatusError( $status ) {
 743+ function showStatusMessage( $status ) {
744744 $text = $status->getWikiText();
745745 $this->output->addWikiText(
746746 "<div class=\"config-message\">\n" .
Index: trunk/phase3/includes/installer/Installer.php
@@ -260,7 +260,7 @@
261261 */
262262 abstract function showMessage( $msg /*, ... */ );
263263
264 - abstract function showStatusError( $status );
 264+ abstract function showStatusMessage( $status );
265265
266266 /**
267267 * Get a list of known DB types
@@ -869,7 +869,7 @@
870870 public function installTables() {
871871 $installer = $this->getDBInstaller();
872872 $status = $installer->createTables();
873 - if( $status->isGood() ) {
 873+ if( $status->isOK() ) {
874874 LBFactory::enableBackend();
875875 }
876876 return $status;
@@ -888,6 +888,9 @@
889889 $file = fopen( "/dev/urandom", "r" );
890890 wfRestoreWarnings();
891891 }
 892+
 893+ $status = Status::newGood();
 894+
892895 if ( $file ) {
893896 $secretKey = bin2hex( fread( $file, 32 ) );
894897 fclose( $file );
@@ -896,10 +899,11 @@
897900 for ( $i=0; $i<8; $i++ ) {
898901 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
899902 }
900 - $this->output->addWarningMsg( 'config-insecure-secretkey' );
 903+ $status->warning( 'config-insecure-secretkey' );
901904 }
902905 $this->setVar( 'wgSecretKey', $secretKey );
903 - return Status::newGood();
 906+
 907+ return $status;
904908 }
905909
906910 public function installSysop() {
Index: trunk/phase3/includes/installer/SqliteInstaller.php
@@ -158,31 +158,27 @@
159159 //@todo or...?
160160 $this->db->reportQueryError( $err, 0, $sql, __FUNCTION__ );
161161 }
162 - $this->setupSearchIndex();
163 - // Create default interwikis
164 - return Status::newGood();
 162+ return $this->setupSearchIndex();
165163 }
166164
167165 function setupSearchIndex() {
168166 global $IP;
169167
 168+ $status = Status::newGood();
 169+
170170 $module = $this->db->getFulltextSearchModule();
171171 $fts3tTable = $this->db->checkForEnabledSearch();
172172 if ( $fts3tTable && !$module ) {
173 - $this->parent->output->addHtml
174 - ( wfMsgHtml( 'word-separator' ) . wfMsgHtml( 'config-sqlite-fts3-downgrade' ) . wfMsgHtml( 'ellipsis' ) );
175 - $this->parent->output->flush();
 173+ $status->warning( 'config-sqlite-fts3-downgrade' );
176174 $this->db->sourceFile( "$IP/maintenance/sqlite/archives/searchindex-no-fts.sql" );
177175 } elseif ( !$fts3tTable && $module == 'FTS3' ) {
178 - $this->parent->output->addHtml
179 - ( wfMsgHtml( 'word-separator' ) . wfMsgHtml( 'config-sqlite-fts3-add' ) . wfMsg( 'ellipsis' ) );
180 - $this->parent->output->flush();
 176+ $status->warning( 'config-sqlite-fts3-add' );
181177 $this->db->sourceFile( "$IP/maintenance/sqlite/archives/searchindex-fts3.sql" );
182178 } else {
183 - $this->parent->output->addHtml
184 - ( wfMsgHtml( 'word-separator' ) . wfMsgHtml( 'config-sqlite-fts3-ok' ) . wfMsgHtml( 'ellipsis' ) );
185 - $this->parent->output->flush();
 179+ $status->warning( 'config-sqlite-fts3-ok' );
186180 }
 181+
 182+ return $status;
187183 }
188184
189185 function doUpgrade() {
Index: trunk/phase3/includes/installer/CliInstaller.php
@@ -62,8 +62,6 @@
6363 if ( isset( $option['pass'] ) ) {
6464 $this->setVar( '_AdminPassword', $option['pass'] );
6565 }
66 -
67 - $this->output = new CliInstallerOutput( $this );
6866 }
6967
7068 /**
@@ -74,22 +72,23 @@
7573 $this->showMessage("Installing $step... ");
7674 $func = 'install' . ucfirst( $step );
7775 $status = $this->{$func}();
78 - $ok = $status->isGood();
79 - if ( !$ok ) {
80 - $this->showStatusError( $status );
 76+ if ( !$status->isOk() ) {
 77+ $this->showStatusMessage( $status );
8178 exit;
 79+ } elseif ( !$status->isGood() ) {
 80+ $this->showStatusMessage( $status );
8281 }
8382 $this->showMessage("done\n");
8483 }
8584 }
8685
8786 function showMessage( $msg /*, ... */ ) {
88 - $this->output->addHTML($msg);
89 - $this->output->output();
 87+ echo html_entity_decode( strip_tags( $msg ), ENT_QUOTES );
 88+ flush();
9089 }
9190
92 - function showStatusError( $status ) {
93 - $this->output->addHTML($status->getWikiText()."\n");
94 - $this->output->flush();
 91+ function showStatusMessage( $status ) {
 92+ $this->showMessage( $status->getWikiText() );
9593 }
 94+
9695 }
Index: trunk/phase3/includes/AutoLoader.php
@@ -414,7 +414,6 @@
415415
416416 # includes/installer
417417 'CliInstaller' => 'includes/installer/CliInstaller.php',
418 - 'CliInstallerOutput' => 'includes/installer/CliInstallerOutput.php',
419418 'Installer' => 'includes/installer/Installer.php',
420419 'InstallerDBType' => 'includes/installer/InstallerDBType.php',
421420 'LBFactory_InstallerFake' => 'includes/installer/Installer.php',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r68645* consolidate some installer functionals into the Installer class...mah21:48, 27 June 2010

Comments

#Comment by Ævar Arnfjörð Bjarmason (talk | contribs)   21:51, 4 July 2010

This solved an issue noted in r65860, and the rest of it looks good.

Status & tagging log