r69215 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69214‎ | r69215 | r69216 >
Date:19:05, 9 July 2010
Author:demon
Status:ok
Tags:
Comment:
Put sanity checks on some of the installer steps. Also make WebInstaller_Install bail if you try a 2nd time
Modified paths:
  • /trunk/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)
  • /trunk/phase3/includes/installer/InstallerDBType.php (modified) (history)
  • /trunk/phase3/includes/installer/MysqlInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstaller.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -417,8 +417,9 @@
418418 'config-extensions-help' => 'The extensions listed above were detected in your <code>./extensions</code> directory.
419419
420420 They may require additional configuration, but you can enable them now',
421 - 'config-install-step-done' => 'Done',
422 - 'config-install-step-failed' => 'Failed',
 421+ 'config-install-alreadydone' => "'''Warning: You seem to have already installed MediaWiki and are trying to install it again. Please proceed to the next page.",
 422+ 'config-install-step-done' => 'done',
 423+ 'config-install-step-failed' => 'failed',
423424 'config-install-extensions' => 'Including extensions',
424425 'config-install-database' => 'Setting up database',
425426 'config-install-pg-schema-failed' => 'Tables creation failed.
@@ -426,8 +427,11 @@
427428 'config-install-user' => 'Creating database user',
428429 'config-install-user-failed' => 'Granting permission to user "$1" failed: $2',
429430 'config-install-tables' => 'Creating tables',
 431+ 'config-install-tables-exist' => "'''Warning''': MediaWiki tables seem to already exist. Skipping creation",
 432+ 'config-install-tables-failed' => "'''Error''': Table creation failed with the following error $1",
430433 'config-install-interwiki' => 'Populating default interwiki table',
431434 'config-install-interwiki-sql' => 'Could not find file <code>interwiki.sql</code>',
 435+ 'config-install-interwiki-exists' => "'''Warning''': Interwiki table seems to already have entires. Skipping default list",
432436 'config-install-secretkey' => 'Generating secret key',
433437 'config-insecure-secretkey' => "'''Warning:''' Unable to create secure <code>\$wgSecretKey</code>.
434438 Consider changing it manually.",
Index: trunk/phase3/includes/installer/WebInstaller.php
@@ -1579,16 +1579,24 @@
15801580 function execute() {
15811581 if( $this->parent->request->wasPosted() ) {
15821582 return 'continue';
 1583+ } elseif( $this->getVar( '_InstallDone' ) ) {
 1584+ $this->startForm();
 1585+ $status = new Status();
 1586+ $status->warning( 'config-install-alreadydone' );
 1587+ $this->parent->showStatusBox( $status );
 1588+ $this->endForm();
 1589+ return true;
 1590+ } else {
 1591+ $this->startForm();
 1592+ $this->addHTML("<ul>");
 1593+ $this->parent->performInstallation(
 1594+ array( $this, 'startStage'),
 1595+ array( $this, 'endStage' )
 1596+ );
 1597+ $this->addHTML("</ul>");
 1598+ $this->endForm();
 1599+ return true;
15831600 }
1584 - $this->startForm();
1585 - $this->addHTML("<ul>");
1586 - $this->parent->performInstallation(
1587 - array( $this, 'startStage'),
1588 - array( $this, 'endStage' )
1589 - );
1590 - $this->addHTML("</ul>");
1591 - $this->endForm();
1592 - return true;
15931601
15941602 }
15951603
Index: trunk/phase3/includes/installer/Installer.php
@@ -51,6 +51,7 @@
5252 '_SafeMode' => false,
5353 '_RaiseMemory' => false,
5454 '_UpgradeDone' => false,
 55+ '_InstallDone' => false,
5556 '_Caches' => array(),
5657 '_InstallUser' => 'root',
5758 '_InstallPassword' => '',
@@ -887,6 +888,7 @@
888889 if( !$status->isOk() )
889890 break;
890891 }
 892+ $this->setVar( '_InstallDone', true );
891893 return $installResults;
892894 }
893895
Index: trunk/phase3/includes/installer/MysqlInstaller.php
@@ -406,7 +406,7 @@
407407 $db = $this->getVar( 'wgDBname' );
408408 $this->db->selectDB( $db );
409409 $error = $this->db->sourceFile( "$IP/maintenance/users.sql" );
410 - if ( !$error ) {
 410+ if ( $error !== true ) {
411411 $status->fatal( 'config-install-user-failed', $this->getVar( 'wgDBuser' ), $error );
412412 }
413413
@@ -420,10 +420,17 @@
421421 return $status;
422422 }
423423 $this->db->selectDB( $this->getVar( 'wgDBname' ) );
424 - if ( !$this->db->sourceFile( "$IP/maintenance/tables.sql" ) ) {
425 - //@todo
 424+
 425+ if( $this->db->tableExists( 'user' ) ) {
 426+ $status->warning( 'config-install-tables-exist' );
 427+ return $status;
 428+ }
 429+
 430+ $error = $this->db->sourceFile( "$IP/maintenance/tables.sql" );
 431+ if( $error !== true ) {
 432+ $status->fatal( 'config-install-tables-failed', $error );
426433 }
427 - return Status::newGood();
 434+ return $status;
428435 }
429436
430437 function getTableOptions() {
Index: trunk/phase3/includes/installer/InstallerDBType.php
@@ -349,6 +349,11 @@
350350 return $status;
351351 }
352352 $this->db->selectDB( $this->getVar( 'wgDBname' ) );
 353+
 354+ if( $this->db->selectRow( 'interwiki', '*', array(), __METHOD__ ) ) {
 355+ $status->warning( 'config-install-interwiki-exists' );
 356+ return $status;
 357+ }
353358 global $IP;
354359 $rows = file( "$IP/maintenance/interwiki.list",
355360 FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );

Status & tagging log