From d7f721d6f920d66f75102723b504d89e57a8c9ff Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 4 Aug 2021 10:36:12 +0200 Subject: [PATCH] Take the array key into account when checking whether a KEY is up to date in DatabaseTableChangeProcessor MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Previously updating a (pretty contrived) KEY that looks like this: […] UNIQUE KEY someIndex (`UNIQUE`) to: […] KEY someIndex (`UNIQUE`) would not do anything. Converted into the `getData()` representation of the PHP DDL API these would look like: [ 'columns' => 'UNIQUE' , 'type' => 'UNIQUE' ] and [ 'columns' => 'UNIQUE' , 'type' => null ] respectively. Now taking the diff of the first array against the second array (subtracting the second from the first) will remove *both* 'UNIQUE' values, resulting in an empty difference, thus believing both KEYs are identical. Fix this issue by using `array_diff_assoc` which will also take the key into account. --- .../database/table/DatabaseTableChangeProcessor.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0e24e5f926..9d49a88cc5 100644 --- a/wcfsetup/install/files/lib/system/database/table/DatabaseTableChangeProcessor.class.php +++ b/wcfsetup/install/files/lib/system/database/table/DatabaseTableChangeProcessor.class.php @@ -500,7 +500,7 @@ class DatabaseTableChangeProcessor { // updating index type and index columns is supported with an // explicit index name is given (automatically generated index // names are not deterministic) - if (!$index->hasGeneratedName() && !empty(array_diff($matchingExistingIndex->getData(), $index->getData()))) { + if (!$index->hasGeneratedName() && !empty(array_diff_assoc($matchingExistingIndex->getData(), $index->getData()))) { if (!isset($this->indicesToDrop[$tableName])) { $this->indicesToDrop[$tableName] = []; } -- 2.20.1