diff --git a/setup.php b/setup.php index e83eb95b..d3d2100e 100644 --- a/setup.php +++ b/setup.php @@ -18,17 +18,23 @@ if ($config_enable_setup == 0) { } $mysqli_available = isset($mysqli) && $mysqli instanceof mysqli; -$db_tables_exist = false; +$can_show_restore = false; +$should_skip_to_user = false; -if ($mysqli_available) { - $check = mysqli_query($mysqli, "SHOW TABLES LIKE 'users'"); - if ($check && mysqli_num_rows($check) > 0) { - $db_tables_exist = true; +if (file_exists("config.php") && $mysqli_available) { + $table_result = mysqli_query($mysqli, "SHOW TABLES LIKE 'users'"); + if ($table_result && mysqli_num_rows($table_result) > 0) { + $can_show_restore = true; + $should_skip_to_user = true; + } else { + // If DB exists but doesn't have user table yet, maybe still allow restore + $all_tables = mysqli_query($mysqli, "SHOW TABLES"); + if ($all_tables && mysqli_num_rows($all_tables) > 0) { + $can_show_restore = true; + } } } -$minimal_setup_mode = file_exists("config.php") && $config_enable_setup == 1 && $mysqli_available && $db_tables_exist; - include_once "includes/settings_localization_array.php"; $errorLog = ini_get('error_log') ?: "Debian/Ubuntu default is usually /var/log/apache2/error.log"; @@ -1063,21 +1069,35 @@ if (isset($_POST['add_telemetry'])) { -
-
-

Restore from Backup

+ +
+
+

Database Not Ready

+
+
+

You must configure the database before restoring a backup.

+ + Go to Database Setup + +
-
-
- - -
- -
+ +
+
+

Restore from Backup

+
+
+
+ + +
+ +
+
-
+ @@ -1388,14 +1408,19 @@ if (isset($_POST['add_telemetry'])) { ?>