diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-05-13 00:32:19 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-05-13 00:32:19 +0000 |
commit | 7008bfb5c3b0654d7d25b2e0d0d53d09e4431c0c (patch) | |
tree | 80574dc1c08ef447cb24f31bcc511ae07f6f4cf1 /installer | |
parent | 847de449968dfc815066eac719ddacf60639206c (diff) |
Warn the user if they're attemping to reinstall into a database that
already has Gallery 3 tables. Otherwise, permit it to continue.
We key this off of the existence of the g3_items table. Theoretically
it's possible that the g3_items table is gone but other tables are
still there, which could mess things up. I'm not going to worry about
that for now.
Fixes ticket #175
Diffstat (limited to 'installer')
-rw-r--r-- | installer/cli.php | 5 | ||||
-rw-r--r-- | installer/installer.php | 3 | ||||
-rw-r--r-- | installer/views/db_not_empty.html.php | 7 |
3 files changed, 9 insertions, 6 deletions
diff --git a/installer/cli.php b/installer/cli.php index a853f67b..199172dc 100644 --- a/installer/cli.php +++ b/installer/cli.php @@ -37,8 +37,9 @@ if (!installer::connect($config)) { oops("Database {$config['dbname']} doesn't exist and can't be created. " . "Please create the database by hand."); } else if (!installer::db_empty($config)) { - oops("Database {$config['dbname']} already has tables in it. " . - "Please specify an empty database.\n"); + oops("Database {$config['dbname']} already has Gallery 3 tables in it. \n" . + " Please remove the Gallery 3 tables, change your prefix,\n" . + " or specify an empty database.\n"); } else if (!installer::unpack_var()) { oops("Unable to create files inside the 'var' directory"); } else if (!installer::unpack_sql($config)) { diff --git a/installer/installer.php b/installer/installer.php index 2a8b6219..55ba4c60 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -76,7 +76,8 @@ class installer { } static function db_empty($config) { - return mysql_num_rows(mysql_query("SHOW TABLES FROM {$config['dbname']}")) == 0; + $query = "SHOW TABLES IN {$config[dbname]} LIKE '{$config[prefix]}items'"; + return mysql_num_rows(mysql_query($query)) == 0; } static function create_admin($config) { diff --git a/installer/views/db_not_empty.html.php b/installer/views/db_not_empty.html.php index 7125a0b6..bc45458d 100644 --- a/installer/views/db_not_empty.html.php +++ b/installer/views/db_not_empty.html.php @@ -1,7 +1,8 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <h1> Uh oh! </h1> <p class="error"> - The database you provided already has other tables in it. - Continuing with the install might overwrite an existing Gallery - install. Please go back and choose a different database. + The database you provided already has Gallery 3 tables in it. + Continuing with the install would overwrite your existing install. + Please either use a different database, delete the old tables, + or choose a different table prefix. </p> |