Review 13.4 Merged

90909[TASK] Upgrade to `doctrine/dbal:~4.3.3`

Stefan Bürk CR +2 V +2 Expert +289 −828 updated 10/06/25, 12:54

Commit message

This change upgrades doctrine/dbal to use `4.3.3` as
the lowest version along with required adjustments to the
extended Doctrine DBAL classes to adapt to ongoing upstream
changes:

MySQL and MariaDB
-----------------

The merged pull-request [1] changes column definition
parsing for MySQL and MariaDB platforms, to which our cloned
`MySQLSchemaManager::getPortableTableColumnDefinition`
is mostly incompatible.

For example, it has been adjusted to keep doc-block based
Doctrine type-configuration working, and ensures `TEXT`
field default values.

Copied code is updated to the current upstream state,
including minor new code cloning.

PostgreSQL
----------

The merged pull-request [2] simplified the schema column
introspection for the PostgresSQL platform. The change
requires the TYPO3 layer of the `PostgreSQLSchemaManager`
to be adopted accordingly.

The underlying code is aligned to the 4.3.x version,
with TYPO3 related adjustments still in place.

SQLite
------

The merged pull-request [3] does not require a change
to the TYPO3 layer, so that only a comment is placed
to align with the other `SchemaManager` changes.

Schema comparison
-----------------

Doctrine added `@final` annotations to two classes as
soft-flag for an upcoming breaking change in Doctrine DBAL 5
and therefore we add these errors to our PHPStan baseline for
now, as the extended classes are still needed and will require
a larger refactoring of our database analyzer stack.

CustomDoctrineTypesColumnDefinitionTrait
----------------------------------------

The purpose of this trait was to handle `enum` and `set`
types during database comparison actions, including
proper sanitization of column default values and reading the
values for these types, to mitigate comparison issues.

Only MySQL and MariaDB support these types. They we initially
implemented directly in TYPO3 and have been – in case of the
`EnumType` – moved to Doctrine in the meantime.

The trait checked for the `dbType` to decide if action needs to be taken
or not, making the trait useless in the following extended SchemaManager:

* PostgreSQLSchemaManager
* SQLiteSchemaManager

The original intention to use the trait in all extended
SchemaManager instances was to have custom handling in
one place and decide on the platform or types.

Meanwhile, the `enum` default value and values parsing
has been integrated in Doctrine DBAL directly and is
no longer needed for this. Having one method cloned
and adjusted to restore custom comment-based type
declaration is not worth a trait. Therefore the trait is now
removed and `set` type handling is integrated directly into the cloned
method in `MySQLSchemaManager::parentGetPortableTableColumnDefinition`.

Trait usage is removed from all schema managers.

SchemaManager unit tests
------------------------

Extended schema manager tests have been implemented as unit
tests using mocked method results, which are technically
wrong. PostgreSQL and SQLite do not support `ENUM` and
`SET` types and the test setup and expectation were wrong.
Corresponding tests along with unit test fixture classes
are now removed.

`MySQLSchemaManagerTest` generally supports `ENUM` and `SET`,
but covering this with a unit test along with
fixture schema manager and mocked column parsing is not
guaranteed to cover future upstream by Doctrine anyway. The tested
values reading from database structure have been integrated into
the `SchemaManagerTest` functional test, testing the creation
for `ENUM` and `SET` fields.

All schema manager unit tests along with fixture extensions are
removed due to being obsolete or replaced with functional tests.

See:

* `SchemaManagerTest::enumTypeFieldCanBeCreated()`
* `SchemaManagerTest::setTypeFieldCanBeCreated()`

Closing words
-------------

Maintaining code adoptions like these is similar to
TYPO3 extensions relying on XCLASSing. The TYPO3 Core
Team strives to align with the Doctrine Team to find
patterns that allow for better integration in frameworks
like TYPO3. This is not a possible short-term scenario
though.

Custom `ENUM` and `SET` type value parsing is adjusted
to respect parsing of a changed database structure due
to the Doctrine DBAL changes. Unit tests are adopted
to provide changes in column data for the expected
structure.

`doctrine/dbal 4.3.0` [1] also contains an important,
performance related change [5] and also the `4.3.1`
bugfix release, which is taken as minimum rule. Using
the `~4.3.3` version constraints limits Doctrine DBAL
to `>=4.3.3 <4.4` following a decision to narrow
Doctrine to patch level upgrades, mitigating possible
breaking updates when newer minor versions of
`doctrine/dbal` doctrine are released, which are possibly
imcompatible with TYPO3 specific platform adaptions and
overrides.

Used command(s):

```
BIN_COMPOSER="$( which composer )" \
&& ${BIN_COMPOSER} require \
  -d typo3/sysext/core --no-update --no-install \
  'doctrine/dbal':'~4.3.3' \
&& ${BIN_COMPOSER} require \
  -d typo3/sysext/install --no-update --no-install \
  'doctrine/dbal':'~4.3.3' \
&& ${BIN_COMPOSER} require \
  -d typo3/sysext/redirects --no-update --no-install \
  'doctrine/dbal':'~4.3.3' \
&& ${BIN_COMPOSER} require -w \
  'doctrine/dbal':'~4.3.3' \
&& Build/Scripts/runTests.sh -s phpstanGenerateBaseline
```

[1] https://github.com/doctrine/dbal/pull/6932
[2] https://github.com/doctrine/dbal/pull/6933
[3] https://github.com/doctrine/dbal/pull/6944
[4] https://github.com/doctrine/dbal/releases/tag/4.3.0
[5] https://github.com/doctrine/dbal/pull/6926
[6] https://github.com/doctrine/dbal/releases/tag/4.3.1
[7] https://github.com/doctrine/dbal/releases/tag/4.3.2
[8] https://github.com/doctrine/dbal/releases/tag/4.3.3

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
  • Verified V +2 Done
    • Stefan Bürk +2
    • core-ci +1 CI

Issues 1

Files 18

Review log 34

  1. Stefan Bürk uploaded patch set 1 10/06/25, 12:00

  2. core-ci voted on patch set 1 V +1 10/06/25, 12:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86069

  3. Stefan Bürk voted on patch set 1 CR +2 V +2 10/06/25, 12:54

  4. Stefan Bürk merged patch set 2 10/06/25, 12:54