From bc0d7981f53b27b9a0b6e3610c083e9bdbcdc205 Mon Sep 17 00:00:00 2001 From: HugoFara Date: Thu, 28 Dec 2023 21:38:09 +0100 Subject: [PATCH] Better detection of file end not read. --- inc/session_utility.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/inc/session_utility.php b/inc/session_utility.php index de6116d8..23d9901a 100644 --- a/inc/session_utility.php +++ b/inc/session_utility.php @@ -4528,11 +4528,7 @@ function restore_file($handle, $title): string $start = true; $curr_content = ''; $queries_list = array(); - while (!feof($handle)) { - $stream = fgets($handle); - if ($stream === false) { - break; - } + while ($stream = fgets($handle)) { // Check file header if ($start) { if (!str_starts_with($stream, "-- lwt-backup-") @@ -4560,7 +4556,11 @@ function restore_file($handle, $title): string foreach ($queries as $query) { $queries_list[] = trim($query); } - } // while (! feof($handle)) + } + if (!feof($handle) && $install_status["errors"] == 0) { + $message = "Error: cannot read the end of the demo file!"; + $install_status["errors"] = 1; + } fclose($handle); // Now run all queries if ($install_status["errors"] == 0) {