Review main Merged

85476[BUGFIX] Avoid array key expansion conflict in SchemaMigrator

Stefan Bürk CR +2 V +2 Easy +2 −2 updated 08/05/24, 20:06

Commit message

TYPO3 builds a virtual database schema reading extension
`ext_tables.sql` files combined with TCA based default
schema definitions to provide the Database Analyzer flow.
The collection process build up partly table structures,
and having tables multiple time which needs to be merged
at some point to get the final virtual structure. With
change #103015 this merge process has been moved to an
earlier point, overseeing that columns and indexes are
no longer associative arrays and using `array_merge()`
is no longer suitable for them.

In cases, where an extensions change or overrides the
table definition of a table this merge process will
throw a Doctrine DBAL `ColumnAlreadyExists` exception,
because columns and indexes of multiple table parts
are not correctly merged anymore. That has been fixed
with #103666 by introducing dedicated merge methods
`mergeColumns()` and `mergeIndexes()` into the class
`SchemaMigrator` and handing over arrays using the
PHP array spread operator `...`.

These are associative arrays and expanding two arrays
into one parameter chain leads to conflicts, if both
arrays contains the same array key throwing a native

  Named parameter $primary overwrites previous argument

error.

For example, the `EXT:static_info_tables` defines the
table structure in a `ext_tables.sql` file and also
in the `ext_tables_static+adt.sql` and using both
files as source during the installation process.

The goal of the dedicated merge methods is to use
the latest index or column and merge the fragmented
tables into one table using the object name to build
a associative array internally and returning only the
array values. That means, the array keys from the outside
is not needed or used anyway and the key spreading can be
be simply discarded using `array_values()` on the input
arrays.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Markus Klein +1
    • Garvin Hicking +1
    • Sebastian Fischer +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Garvin Hicking +1
    • Sebastian Fischer +1
    • core-ci +1 CI

Issues 4

Files 1

Review log 810

  1. Stefan Bürk uploaded patch set 1 08/01/24, 21:25

  2. Sebastian Fischer voted on patch set 1 CR +1 V +1 08/01/24, 21:29

  3. Markus Klein updated the commit message in patch set 2 CR +1 V +1 08/01/24, 21:30

  4. Markus Klein commented on patch set 2 CR +1 08/01/24, 21:31

    Fixed a typo in the commit msg and removed the last (incorrect) sentence
  5. Sebastian Fischer voted on patch set 2 CR +1 V +1 08/01/24, 21:36

  6. core-ci voted on patch set 2 V +1 08/01/24, 21:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62672

  7. core-ci voted on patch set 1 V +1 08/01/24, 21:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62670

  8. Garvin Hicking voted on patch set 2 CR +1 V +1 08/05/24, 19:05

  9. Georg Ringer voted on patch set 2 CR +2 V +2 08/05/24, 20:06

  10. Georg Ringer merged patch set 3 08/05/24, 20:06