Issue Bug Closed

#110255Fix broken TableDiff::getDroppedForeignKeyConstraintNames()

Stefan Bürk 07/21/26, 18:46 updated 08/11/26, 08:51

Description

`TYPO3\CMS\Core\Database\Schema\TableDiff` extends the Doctrine DBAL `TableDiff`
and deliberately does not call the parent constructor, because it re-declares all
constructor properties as public to restore direct property access. Doctrine
declares them as `private readonly`, so parent and child hold two distinct
properties of the same name.

Every inherited getter TYPO3 relies on is overridden accordingly – except
`getDroppedForeignKeyConstraintNames()`, which Doctrine added in 4.4 as the
replacement for the now deprecated `getDroppedForeignKeys()`. That method reads
the Doctrine property directly, which is never initialised for a TYPO3
`TableDiff`, so any call fails:

Error: Typed property Doctrine\DBAL\Schema\TableDiff::$droppedForeignKeys
must not be accessed before initialization

Reproduce:

$diff = new \TYPO3\CMS\Core\Database\Schema\TableDiff(new \Doctrine\DBAL\Schema\Table(‘a_table’));
$diff->getDroppedForeignKeyConstraintNames();

Nothing in TYPO3 or in Doctrine DBAL 4.4 calls the method yet, so the defect is
latent today. It becomes reachable as soon as the schema managers switch to the
new API, which happens with Doctrine DBAL 5.0.

The two other inherited methods reading Doctrine properties,
`getModifiedColumns()` and `getRenamedColumns()`, are not affected: both go
through the overridden `getChangedColumns()`.

Resolution: override the method, reading the re-declared property, keeping the
parent behaviour including the `InvalidState` exception for unnamed constraints.
Additionally the `@deprecated` annotations of the overridden parent methods
`getModifiedIndexes()`, `getModifiedForeignKeys()` and `getDroppedForeignKeys()`
are adopted from the parent, as overriding a method drops the inherited docblock
and with it the deprecation notice for IDEs and static analysis.

Purely additive, no behaviour change for existing callers.

Reviews 3