Review main Merged

82076[TASK] Mitigate deprecated doctrine `SchemaDiff` methods

Stefan Bürk CR +2 V +2 Normal +92 −18 updated 12/18/23, 11:27

Commit message

The doctrine team deprecated the `SchemaDiff->toSql()` and
`SchemaDiff->toSaveSql()` methods [1], `toSaveSql()` without
a replacement.

Both methods are used in the TYPO3 database analyzer build
up - and the behaviour of replaceless deprecated `toSaveSql()`
is a essential used feature. In the current state there is
no good solution to mitigate this, therefore a temporary
`getSaveAlterSchemaSQL()` should be added as a wrapper. For
now dispatch to the deprecated `SchemaDiff->toSaveSql()` and
replace the body with corresponding code during the upgrade
for `Doctrine DBAL 4` - marked with a todo comment.

The whole schema and connection migrator implementation
is scheduled for a refactoring due to needs of further features,
so postpone a refactoring now and use this smelly hack.

This change ...

* adds a trait `PlatformSaveAlterSchemaSQLTrait` providing the
  `getSaveAlterSchemaSQL()` wrapper method.
* adds the trait `PlatformSaveAlterSchemaSQLTrait` to all
  extended platform classes (#102402).
* replaces deprecated `SchemaDiff->toSql()` calls with
  `AbstractPlatform::getAlterSchemaSQL()`.
* replace `SchemaDiff->toSaveSql()` calls with extended
  platform method `AbstractPlatform::getSaveAlterSchemaSQL()`.

[1] https://github.com/doctrine/dbal/blob/3.7.x/UPGRADE.md#deprecated-schemadifftosql-and-schemadifftosavesql

Review

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

Issues 2

Files 14

Review log 1114

  1. Stefan Bürk uploaded patch set 1 12/03/23, 15:29

  2. core-ci voted on patch set 1 V +1 12/03/23, 15:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50282

  3. Stefan Bürk wrote 12/03/23, 15:57

    Topic set to doctrine-dbal
  4. Oliver Klee commented on patch set 1 12/03/23, 16:30

    I don't quite understand the name of the new temporary method. Maybe I can come up with a more communicative name after I have understood the current name. It is about "saving" (i.e., storing) something, or is it about something "safe" (i.e., not risky)?
  5. Stefan Bürk commented on patch set 1 12/03/23, 16:51

    Reply

    Basically it's more about beeing "not risky" (safe). The naming is taken from the old doctrine naming, and I would keep that for now. Both are not really usefull here. There it was more for "save sql in a safe state". It's a pure internal implementation for now and the plan is to refactor this in some way, but TBH not a final plan on how yet. Decided to go with this to have this prepartion unblocked for the Doctrine DBAL 4 upgrade and deal with a generic refactoring later. Doctrine DBAL 4 will introduce breaking stuff, so we need to have it in until 13.0 - the refactoring of the internal classes can be done in the further 13.x development time frame as the database analyser stack is internal. See docblock from the deprecated `toSaveSql()` method: ```php /** * The to save sql mode ensures that the following things don't happen: * * 1. Tables are deleted * 2. Sequences are deleted * 3. Foreign Keys which reference tables that would otherwise be deleted. * * This way it is ensured that assets are deleted which might not be relevant to the metadata schema at all. * * @deprecated * * @return list<string> */ public function toSaveSql(AbstractPlatform $platform) ``` Therefore, I will keep the nameing as a endless "naming discussion" block would break the overall timeschedule for nothing.
  6. Oliver Klee commented on patch set 1 12/03/23, 20:18

    Reply

    Ack - thanks for the explanation!
  7. Stefan Bürk rebased onto patch set 2 V +1 12/08/23, 12:35

  8. core-ci voted on patch set 2 V +1 12/08/23, 12:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50497

  9. Stefan Bürk rebased onto patch set 3 V +1 12/14/23, 07:52

  10. core-ci voted on patch set 3 V +1 12/14/23, 08:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50638

  11. Oliver Klee voted on patch set 3 CR +1 V +1 12/14/23, 12:16

  12. Christian Kuhn voted on patch set 3 CR +1 V +1 12/18/23, 11:15

  13. Stefan Bürk voted on patch set 3 CR +2 V +2 12/18/23, 11:26

  14. Stefan Bürk merged patch set 4 12/18/23, 11:27