From 5289d41b0b467bbf6bdcb2f17e137c3ea06954d4 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Fri, 9 Jul 2010 19:05:48 +0000 Subject: [PATCH] Put sanity checks on some of the installer steps. Also make WebInstaller_Install bail if you try a 2nd time --- includes/installer/Installer.i18n.php | 8 ++++++-- includes/installer/Installer.php | 2 ++ includes/installer/InstallerDBType.php | 5 +++++ includes/installer/MysqlInstaller.php | 15 +++++++++++---- includes/installer/WebInstaller.php | 26 +++++++++++++++++--------- 5 files changed, 41 insertions(+), 15 deletions(-) diff --git a/includes/installer/Installer.i18n.php b/includes/installer/Installer.i18n.php index eff283bd2b..17bff64e51 100644 --- a/includes/installer/Installer.i18n.php +++ b/includes/installer/Installer.i18n.php @@ -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 ./extensions 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 interwiki.sql', + '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 \$wgSecretKey. Consider changing it manually.", diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 2366ad21ed..290b579cee 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -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; } diff --git a/includes/installer/InstallerDBType.php b/includes/installer/InstallerDBType.php index 008161280d..08c25f1f1f 100644 --- a/includes/installer/InstallerDBType.php +++ b/includes/installer/InstallerDBType.php @@ -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 ); diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 4b0cd9ba6b..5db3af37ef 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -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() { diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index 66e9d45ae0..0d3e88ab50 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -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(""); + $this->endForm(); + return true; } - $this->startForm(); - $this->addHTML(""); - $this->endForm(); - return true; } -- 2.20.1