Skip to content

Commit f85d1a5

Browse files
committed
[BUGFIX] Ensure table renaming works due doctrine/dbal behaviour change
doctrine/dbal is working on deprecating and changing code and behaviour in 3.x as preparation for removal in 4.x. Starting with doctrine/dbal v3.5.0, the table rename detection in the TYPO3 database compare no longer works as expected. TableDiff got an `isEmpty()` check, which is used in SchemaDiff and thus filtering out "renamed" tables without further changes, leading to a change of behavior. doctrine/dbal favors renaming table no longer by setting a new name in the TableDiff, thus not having the changed name in the `isEmpty()` check. See: doctrine/dbal#5770 doctrine/dbal deprecations and changes require systematical adoption to cover all the changes. This takes time and proper testing, which is out of the scope for this change. This change overrides the `TableDiff->isEmpty()` method in the corresponding core fascade class, adding checks for $newName and $tableOptions checks as a intermediate workaround. Thus keep compatibillity between doctrine/dbal <3.5 and 3.5 for now. Resolves: #98707 Releases: main Change-Id: If305e4d809be29585e0b6a72c3215f5cff68762d Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76232 Tested-by: core-ci <[email protected]> Tested-by: Christian Kuhn <[email protected]> Tested-by: Benni Mack <[email protected]> Tested-by: Stefan Bürk <[email protected]> Reviewed-by: Christian Kuhn <[email protected]> Reviewed-by: Benni Mack <[email protected]> Reviewed-by: Stefan Bürk <[email protected]>
1 parent 8dafa67 commit f85d1a5

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

typo3/sysext/core/Classes/Database/Schema/ConnectionMigrator.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,6 @@ protected function getUnusedTableUpdateSuggestions(SchemaDiff $schemaDiff): arra
676676
);
677677

678678
$statements = $changedFieldDiff->toSql($this->connection->getDatabasePlatform());
679-
680679
foreach ($statements as $statement) {
681680
$updateSuggestions['change_table'][md5($statement)] = $statement;
682681
}

typo3/sysext/core/Classes/Database/Schema/TableDiff.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,27 @@ public function getTableOption(string $optionName): string
7878

7979
return '';
8080
}
81+
82+
/**
83+
* @return bool
84+
*/
85+
public function isEmpty(): bool
86+
{
87+
return count($this->addedColumns) === 0
88+
&& count($this->changedColumns) === 0
89+
&& count($this->removedColumns) === 0
90+
&& count($this->renamedColumns) === 0
91+
&& count($this->addedIndexes) === 0
92+
&& count($this->changedIndexes) === 0
93+
&& count($this->removedIndexes) === 0
94+
&& count($this->renamedIndexes) === 0
95+
&& count($this->addedForeignKeys) === 0
96+
&& count($this->changedForeignKeys) === 0
97+
&& count($this->removedForeignKeys) === 0
98+
// @todo Recheck this after proper table rename strategy has been evolved. Related to doctrine/dbal 3.5 changes.
99+
&& $this->newName === false
100+
// @todo doctrine/dbal 3.5 deprecated schema events, thus a new way to provide table option has to
101+
// be found and implemented. Recheck this afterwards.
102+
&& $this->tableOptions === [];
103+
}
81104
}

0 commit comments

Comments
 (0)