Review main Abandoned

87791[BUGFIX] Replace extended ColumnDiff by using PHP Reflection API

Stefan Bürk CR 0 V 0 Normal +8 −125 updated 01/17/25, 17:29

Commit message

Release `Doctrine/DBAL 4.2.2` [1] includes a change to consider
column platform options as change to support PostgreSQL `JSONB`.

Doctrine introduced method `ColumnDiff::hasPlatformOptionsChanged()`
to accomplish to check that in different places.

TYPO3 extends the `ColumnDiff` class due to some requirements not
having the new method on board but changing the visibility of the
two colum properties to public. That leads to calling the parent
method trying to use the private properties which are not set and
ending up in TypeError during the database compare for PostgreSQL
with Doctrine DBAL 4.2.2.

Extended class has been added to change the identifier quoting
for the old column in `ConnectionMigrator`.

This change uses PHP Reflection API to call the protected method
`Column::_setName()` to ensure correct column name quoting within
the `ConnectionMigrator` and make the TYPO3 `ColumnDiff` extended
class obsolete and is removed now. Database Analyzer realted classes
are internal implementation and removal considerable non-breaking.

Composer based instances should either add a conflict for doctrine
or pin it to 4.2.1 as intermediate mitigation using for example:

> composer require "doctrine/dbal":"<4.2.2"

and remove it when upgrading to TYPO3 version containing this fix.

[1] https://github.com/doctrine/dbal/releases/tag/4.2.2
[2] https://github.com/doctrine/dbal/pull/6693

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 3

Review log 1215

  1. Stefan Bürk uploaded patch set 1 01/17/25, 15:36

  2. core-ci voted on patch set 1 V +1 01/17/25, 15:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72621

  3. Benjamin Franzke commented on patch set 1 01/17/25, 16:14

    ColumnDiff.php:24

    How about dismantling this class and remove all methods (and remove the wrapper in v14 entirely) to not overwrite the constructor anymore and use ReflectionProperty for property access in ConnectionMigrator? It seems like we could face this issue anytime, whenever doctrine adds a new method that accesses oldColumn or newColumn. Or maybe the property is even entirely uneeded? It seems like oldColumn is quoted twice: https://github.com/TYPO3/typo3/blob/052b80b2d0b49bb6c3078e943b4a2ba1babd512b/typo3/sysext/core/Classes/Database/Schema/ConnectionMigrator.php#L1271 and https://github.com/TYPO3/typo3/blob/052b80b2d0b49bb6c3078e943b4a2ba1babd512b/typo3/sysext/core/Classes/Database/Schema/ConnectionMigrator.php#L720
  4. Benjamin Franzke commented on patch set 1 01/17/25, 16:23

    ColumnDiff.php:24 Reply

    nvm, I guess the second case applies escaping to the diff initialized in https://github.com/TYPO3/typo3/blob/052b80b2d0b49bb6c3078e943b4a2ba1babd512b/typo3/sysext/core/Classes/Database/Schema/TableDiff.php#L235 (maybe we could escape directly). anyway, I'll close this comment for now.
  5. Stefan Bürk commented on patch set 1 CR -1 01/17/25, 16:28

    ColumnDiff.php:24 Reply

    > It seems like oldColumn is quoted twice: Nope, `buildQuoteColumn()` unquotes the name first, see https://github.com/TYPO3/typo3/blob/052b80b2d0b49bb6c3078e943b4a2ba1babd512b/typo3/sysext/core/Classes/Database/Schema/ConnectionMigrator.php#L1494 Otherwise, good point. Checking now if we can drop the extended ColumnDiff completly.
  6. Sebastian Iffland commented on patch set 1 01/17/25, 16:41

    ColumnDiff.php:118

    As targeting branches supporting PHP 8.3+ I'd propose applying [#\[\Override\]](https://php.watch/versions/8.3/override-attr)attribute.
  7. Sebastian Iffland commented on patch set 1 01/17/25, 16:43

    ColumnDiff.php:118 Reply

    nvm, just checked development roadmap and 13.4 still provides support for 8.2
  8. Stefan Bürk uploaded patch set 2 CR -1 V +1 01/17/25, 17:04

  9. core-ci voted on patch set 2 V +1 01/17/25, 17:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72630

  10. Benjamin Franzke commented on patch set 2 01/17/25, 17:15

    ColumnDiff.php:24 Reply

    that should actually work by composing a new `ColumnDiff` object instead of modyfing the existing one. Tried this here, maybe we can pick that route: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87792
  11. Stefan Bürk commented on patch set 2 01/17/25, 17:15

    ColumnDiff.php:24 Reply

    @ben@bnf.dev Switched to reflection in the one place in ConnectionMigrator to make the custom ColumnDiff obsolete and removed it. Also removed the dbal rise from this change now, we can do that in a dedicated change. Does the solution now goes in the direction you had in mind ?
  12. Benjamin Franzke commented on patch set 2 01/17/25, 17:17

    ColumnDiff.php:24 Reply

    yes, but then I figured we do not need reflection at all, as we can compose a new instance. Sorry, we overlapped here, I tried that in https://review.typo3.org/c/Packages/TYPO3.CMS/+/87792 in parallel to your change, sorry :\
  13. core-ci commented on patch set 2 01/17/25, 17:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72631

  14. Stefan Bürk commented on patch set 2 01/17/25, 17:28

    ColumnDiff.php:24 Reply Unresolved

    Everything fine, going to abandon mine in favor of yours to also avoid the reflection.
  15. Stefan Bürk abandoned the change 01/17/25, 17:29