Put sanity checks on some of the installer steps. Also make WebInstaller_Install...
authorChad Horohoe <demon@users.mediawiki.org>
Fri, 9 Jul 2010 19:05:48 +0000 (19:05 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Fri, 9 Jul 2010 19:05:48 +0000 (19:05 +0000)
includes/installer/Installer.i18n.php
includes/installer/Installer.php
includes/installer/InstallerDBType.php
includes/installer/MysqlInstaller.php
includes/installer/WebInstaller.php

index eff283b..17bff64 100644 (file)
@@ -417,8 +417,9 @@ Should be separated with commas and specify the port to be used (for example: 12
        'config-extensions-help'          => 'The extensions listed above were detected in your <code>./extensions</code> directory.
 
 They may require additional configuration, but you can enable them now',
-       'config-install-step-done'        => 'Done',
-       'config-install-step-failed'      => 'Failed',
+       'config-install-alreadydone'      => "'''Warning: You seem to have already installed MediaWiki and are trying to install it again. Please proceed to the next page.",
+       'config-install-step-done'        => 'done',
+       'config-install-step-failed'      => 'failed',
        'config-install-extensions'       => 'Including extensions',
        'config-install-database'         => 'Setting up database',
        'config-install-pg-schema-failed' => 'Tables creation failed.
@@ -426,8 +427,11 @@ Make sure that the user "$1" can write to the schema "$2".',
        'config-install-user'             => 'Creating database user',
        'config-install-user-failed'      => 'Granting permission to user "$1" failed: $2',
        'config-install-tables'           => 'Creating tables',
+       'config-install-tables-exist'     => "'''Warning''': MediaWiki tables seem to already exist. Skipping creation",
+       'config-install-tables-failed'    => "'''Error''': Table creation failed with the following error $1",
        'config-install-interwiki'        => 'Populating default interwiki table',
        'config-install-interwiki-sql'    => 'Could not find file <code>interwiki.sql</code>',
+       'config-install-interwiki-exists' => "'''Warning''': Interwiki table seems to already have entires. Skipping default list",
        'config-install-secretkey'        => 'Generating secret key',
        'config-insecure-secretkey'       => "'''Warning:''' Unable to create secure <code>\$wgSecretKey</code>.
 Consider changing it manually.",
index 2366ad2..290b579 100644 (file)
@@ -51,6 +51,7 @@ abstract class Installer {
                '_SafeMode' => false,
                '_RaiseMemory' => false,
                '_UpgradeDone' => false,
+               '_InstallDone' => false,
                '_Caches' => array(),
                '_InstallUser' => 'root',
                '_InstallPassword' => '',
@@ -887,6 +888,7 @@ abstract class Installer {
                        if( !$status->isOk() )
                                break;
                }
+               $this->setVar( '_InstallDone', true );
                return $installResults;
        }
 
index 0081612..08c25f1 100644 (file)
@@ -349,6 +349,11 @@ abstract class InstallerDBType {
                        return $status;
                }
                $this->db->selectDB( $this->getVar( 'wgDBname' ) );
+
+               if( $this->db->selectRow( 'interwiki', '*', array(), __METHOD__ ) ) {
+                       $status->warning( 'config-install-interwiki-exists' );
+                       return $status;
+               }
                global $IP;
                $rows = file( "$IP/maintenance/interwiki.list",
                        FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
index 4b0cd9b..5db3af3 100644 (file)
@@ -406,7 +406,7 @@ class MysqlInstaller extends InstallerDBType {
                $db = $this->getVar( 'wgDBname' );
                $this->db->selectDB( $db );
                $error = $this->db->sourceFile( "$IP/maintenance/users.sql" );
-               if ( !$error ) {
+               if ( $error !== true ) {
                        $status->fatal( 'config-install-user-failed', $this->getVar( 'wgDBuser' ), $error );
                }
 
@@ -420,10 +420,17 @@ class MysqlInstaller extends InstallerDBType {
                        return $status;
                }
                $this->db->selectDB( $this->getVar( 'wgDBname' ) );
-               if ( !$this->db->sourceFile( "$IP/maintenance/tables.sql" ) ) {
-                       //@todo
+               
+               if( $this->db->tableExists( 'user' ) ) {
+                       $status->warning( 'config-install-tables-exist' );
+                       return $status;
+               } 
+               
+               $error = $this->db->sourceFile( "$IP/maintenance/tables.sql" );
+               if( $error !== true ) {
+                       $status->fatal( 'config-install-tables-failed', $error );
                }
-               return Status::newGood();
+               return $status;
        }
 
        function getTableOptions() {
index 66e9d45..0d3e88a 100644 (file)
@@ -1579,16 +1579,24 @@ class WebInstaller_Install extends WebInstallerPage {
        function execute() {
                if( $this->parent->request->wasPosted() ) {
                        return 'continue';
+               } elseif( $this->getVar( '_InstallDone' ) ) {
+                       $this->startForm();
+                       $status = new Status();
+                       $status->warning( 'config-install-alreadydone' );
+                       $this->parent->showStatusBox( $status );
+                       $this->endForm();
+                       return true;
+               } else {
+                       $this->startForm();
+                       $this->addHTML("<ul>");
+                       $this->parent->performInstallation(
+                               array( $this, 'startStage'),
+                               array( $this, 'endStage' )
+                       );
+                       $this->addHTML("</ul>");
+                       $this->endForm();
+                       return true;
                }
-               $this->startForm();
-               $this->addHTML("<ul>");
-               $this->parent->performInstallation(
-                       array( $this, 'startStage'), 
-                       array( $this, 'endStage' )
-               );
-               $this->addHTML("</ul>");
-               $this->endForm();
-               return true;
 
        }