From 782d692b5a3c8944beb5bc388d934db53ff76e82 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 17 Mar 2018 09:04:38 +0000 Subject: [PATCH 1/2] Possible fix issue 4611: Don't write to database before it is created --- mod/install.php | 2 +- src/Database/DBStructure.php | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mod/install.php b/mod/install.php index 3adcb75aa4..4b4940d277 100644 --- a/mod/install.php +++ b/mod/install.php @@ -540,7 +540,7 @@ function load_database_rem($v, $i) { } function load_database() { - $errors = DBStructure::update(false, true); + $errors = DBStructure::update(false, true, true); return $errors; } diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index a1ef3374f9..b8eea03e11 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -203,8 +203,8 @@ class DBStructure * @param array $definition An array of the definition tables * @return string Empty string if the update is successful, error messages otherwise */ - public static function update($verbose, $action, array $tables = null, array $definition = null) { - if ($action) { + public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) { + if ($action && !$install) { Config::set('system', 'maintenance', 1); Config::set('system', 'maintenance_reason', L10n::t(': Database update', DBM::date().' '.date('e'))); } @@ -455,7 +455,9 @@ class DBStructure } if ($action) { - Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name)); + if (!$install) { + Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name)); + } // Ensure index conversion to unique removes duplicates if ($is_unique && ($temp_name != $name)) { @@ -505,15 +507,15 @@ class DBStructure } } - if ($action) { + if ($action && !$install) { Config::set('system', 'maintenance', 0); Config::set('system', 'maintenance_reason', ''); - } - if ($errors) { - Config::set('system', 'dbupdate', DB_UPDATE_FAILED); - } else { - Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL); + if ($errors) { + Config::set('system', 'dbupdate', DB_UPDATE_FAILED); + } else { + Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL); + } } return $errors; From 537ef83a24d966b5c177c0198d7723166d6bf450 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 17 Mar 2018 09:21:06 +0000 Subject: [PATCH 2/2] If we aren't connected to the database, we shouldn't return "true" on connect --- include/dba.php | 1 + 1 file changed, 1 insertion(+) diff --git a/include/dba.php b/include/dba.php index 9ac26aaa10..fc54eefeb3 100644 --- a/include/dba.php +++ b/include/dba.php @@ -101,6 +101,7 @@ class dba { if (!$install) { System::unavailable(); } + return false; } $a->save_timestamp($stamp1, "network");