From: Tim Düsterhus Date: Tue, 21 Sep 2021 14:31:17 +0000 (+0200) Subject: Take the array key into account when checking whether an unnamed KEY matches in Datab... X-Git-Tag: 5.4.8_dev_1~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bba6c47145d44928b22be80b057cfefd1b386f8f;p=GitHub%2FWoltLab%2FWCF.git Take the array key into account when checking whether an unnamed KEY matches in DatabaseTableChangeProcessor The reproducer effectively matches d7f721d6f920d66f75102723b504d89e57a8c9ff, except that the KEY is unnamed. Previously the update would silently fail to do anything. Now the update fails loudly, because it attempts to create another index with an existing name. This is no different behavior compared to an INDEX collision of two unnamed indices `(a, b)`, `(a, c)`. The developer will be clearly alerted of this issue and can take appropriate measures to avoid it, e.g. by using explicit names. see #4434 --- 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 3ee2a2b7b6..7e555f88b3 100644 --- a/wcfsetup/install/files/lib/system/database/table/DatabaseTableChangeProcessor.class.php +++ b/wcfsetup/install/files/lib/system/database/table/DatabaseTableChangeProcessor.class.php @@ -821,7 +821,7 @@ class DatabaseTableChangeProcessor protected function diffIndices(DatabaseTableIndex $oldIndex, DatabaseTableIndex $newIndex) { if ($newIndex->hasGeneratedName()) { - return !empty(\array_diff($oldIndex->getData(), $newIndex->getData())); + return !empty(\array_diff_assoc($oldIndex->getData(), $newIndex->getData())); } return $oldIndex->getName() !== $newIndex->getName();