From c519eeeae5e64104b2c99374314150ead24b9f7e Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 6 Oct 2019 14:06:26 +0200 Subject: [PATCH] Fix default column value comparison between strings and ints --- .../table/DatabaseTableChangeProcessor.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/system/database/table/DatabaseTableChangeProcessor.class.php b/wcfsetup/install/files/lib/system/database/table/DatabaseTableChangeProcessor.class.php index 6a0edd586f..43e4b88010 100644 --- a/wcfsetup/install/files/lib/system/database/table/DatabaseTableChangeProcessor.class.php +++ b/wcfsetup/install/files/lib/system/database/table/DatabaseTableChangeProcessor.class.php @@ -666,9 +666,16 @@ class DatabaseTableChangeProcessor { return true; } - // default type has to be checked with a strict check to differentiate between having - // no default value (`null`) and having an empty string as default value - return $oldColumn->getDefaultValue() !== $newColumn->getDefaultValue(); + // default type has to be checked explicitly for `null` to properly detect changing + // from no default value (`null`) and to an empty string as default value (and vice + // versa) + if ($oldColumn->getDefaultValue() === null || $newColumn->getDefaultValue() === null) { + return $oldColumn->getDefaultValue() !== $newColumn->getDefaultValue(); + } + + // for all other cases, use weak comparison so that `'1'` (from database) and `1` + // (from script PIP) match, for example + return $oldColumn->getDefaultValue() != $newColumn->getDefaultValue(); } /** -- 2.20.1