From 8d9eaa8ff1d82231f6fdcf4296100c4ffc9cf4a9 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 24 Nov 2017 13:11:56 +0100 Subject: Installer: Properly check preconditions for adding constraints --- install.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'install.php') 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; } -- cgit v1.2.3-55-g7522