From: Matthias Schmidt Date: Sun, 6 Oct 2019 12:06:26 +0000 (+0200) Subject: Fix default column value comparison between strings and ints X-Git-Tag: 5.2.0_Beta_2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c519eeeae5e64104b2c99374314150ead24b9f7e;p=GitHub%2FWoltLab%2FWCF.git Fix default column value comparison between strings and ints --- 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(); } /**