Merge pull request #4617 from annando/issue-4611

Possible fix issue 4611: Don't write to database before it is created
This commit is contained in:
Tobias Diekershoff 2018-03-17 10:29:55 +01:00 committed by GitHub
commit fea18c11ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 10 deletions

View file

@ -101,6 +101,7 @@ class dba {
if (!$install) { if (!$install) {
System::unavailable(); System::unavailable();
} }
return false;
} }
$a->save_timestamp($stamp1, "network"); $a->save_timestamp($stamp1, "network");

View file

@ -540,7 +540,7 @@ function load_database_rem($v, $i) {
} }
function load_database() { function load_database() {
$errors = DBStructure::update(false, true); $errors = DBStructure::update(false, true, true);
return $errors; return $errors;
} }

View file

@ -203,8 +203,8 @@ class DBStructure
* @param array $definition An array of the definition tables * @param array $definition An array of the definition tables
* @return string Empty string if the update is successful, error messages otherwise * @return string Empty string if the update is successful, error messages otherwise
*/ */
public static function update($verbose, $action, array $tables = null, array $definition = null) { public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) {
if ($action) { if ($action && !$install) {
Config::set('system', 'maintenance', 1); Config::set('system', 'maintenance', 1);
Config::set('system', 'maintenance_reason', L10n::t(': Database update', DBM::date().' '.date('e'))); Config::set('system', 'maintenance_reason', L10n::t(': Database update', DBM::date().' '.date('e')));
} }
@ -455,7 +455,9 @@ class DBStructure
} }
if ($action) { if ($action) {
if (!$install) {
Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name)); Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name));
}
// Ensure index conversion to unique removes duplicates // Ensure index conversion to unique removes duplicates
if ($is_unique && ($temp_name != $name)) { if ($is_unique && ($temp_name != $name)) {
@ -505,16 +507,16 @@ class DBStructure
} }
} }
if ($action) { if ($action && !$install) {
Config::set('system', 'maintenance', 0); Config::set('system', 'maintenance', 0);
Config::set('system', 'maintenance_reason', ''); Config::set('system', 'maintenance_reason', '');
}
if ($errors) { if ($errors) {
Config::set('system', 'dbupdate', DB_UPDATE_FAILED); Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
} else { } else {
Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL); Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
} }
}
return $errors; return $errors;
} }