diff options
author | Simon Rettberg | 2017-11-24 13:11:56 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-11-24 13:11:56 +0100 |
commit | 8d9eaa8ff1d82231f6fdcf4296100c4ffc9cf4a9 (patch) | |
tree | f051858c0cc2953a02b85b2d9aa4fc85fa6b4e71 /install.php | |
parent | [statistics] Warn about suspicious hardware changes (RAM, CPU) (diff) | |
download | slx-admin-8d9eaa8ff1d82231f6fdcf4296100c4ffc9cf4a9.tar.gz slx-admin-8d9eaa8ff1d82231f6fdcf4296100c4ffc9cf4a9.tar.xz slx-admin-8d9eaa8ff1d82231f6fdcf4296100c4ffc9cf4a9.zip |
Installer: Properly check preconditions for adding constraints
Diffstat (limited to 'install.php')
-rw-r--r-- | install.php | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/install.php b/install.php index 1345a6bd..b736713f 100644 --- a/install.php +++ b/install.php @@ -140,11 +140,16 @@ function tableGetContraints($table, $column, $refTable, $refColumn) */ function tableAddConstraint($table, $column, $refTable, $refColumn, $actions) { - $test = tableGetConstraints($table, $column, $refTable, $refColumn); + $test = tableExists($refTable) && tableHasColumn($refTable, $refColumn); if ($test === false) { - // Most likely, destination table does not exist yep + // Most likely, destination table does not exist yet or isn't up to date return UPDATE_RETRY; } + $test = tableGetConstraints($table, $column, $refTable, $refColumn); + if ($test === false) { + // Should never happen!? + finalResponse(UPDATE_FAILED, 'DB: Cannot query constraints: ' . Database::lastError()); + } if (!empty($test)) { // Already exists return UPDATE_NOOP; @@ -154,7 +159,7 @@ function tableAddConstraint($table, $column, $refTable, $refColumn, $actions) REFERENCES `$refTable` (`$refColumn`) $actions"); if ($ret === false) { - finalResponse(UPDATE_FAILED, 'DB-Error: ' . Database::lastError()); + finalResponse(UPDATE_FAILED, 'DB: Cannot add constraint: ' . Database::lastError()); } return UPDATE_DONE; } |