Review 13.4 Merged

90947[TASK] Streamline `SchemaInformation` cache handling

Stefan Bürk CR +2 V +2 Hard +281 −71 updated 10/07/25, 13:20

Commit message

During introducing of the native json field support the custom
(and internal) `SchemaInformation` class has been implemented [1],
which was required to provide a cache layer to reduce cost related
database schema lookups in a handfull of places.

The cache layer has been changed from core cache to a dedicated
`database_schema` cache to use the VariableFrontend per default,
using `serialize/deserialize` under the hood later on [2].

Once we tried to replace even more costly database schema calls in
TYPO3 [3] an issue with the caching of Doctrine DBAL schema objects
was revealed and the respective change got reverted [4].

Further investigation revealed, that we actually only need a very
specific subset of schema information in several places of our
beloved CMS, which nails down to:

* list table names of a database connection
* list table column names for a database of a connection
* list table columns to get information required to make
  decision how to process things in a handfull of places.

`SchemaInformation` was never ment to provide a complete
cached replacement for the database schema methods provided
by `AbstractSchemaManager` from Doctrine DBAL, the goal
was to only have necessary data cached to reduce database
queries to slow schema information tables.

This change takes all of the points into account:

* Add `ColumnInfo` to hold subset column schema information
  for one table column prepared to be unserializable and
  serializable.

* Add `TableInfo` providing a small container to hold the
  `ColumnInfo` information objects of a table prepared to
  be serializeable/unserializable.

* `SchemaInformation` implementation is streamlined, adding
  private build:

    * `buildTableNames()`: Build table names list for the
      connection and cache it, using a cheaper method to
      retrieve the table names in the connection.
    * `buildTableInformation(): Build up simplified table
      and table column information based on new DTO's and
      cache them for specified table.

* Added `SchemaInformation->getTableInfo(string $tableName)`
  to get minimuzed `TableInfo` including `ColumnInfo's`.

* Adding `listTableColumnNames(string $tableName)` as simple
  method to get only table column names using the `TableInfo`
  cache for specified table.

* Adding `listTableColumnInfos(string $table)` to retrieve
  an associative array of table column infos, using the
  `TableInfo()` cache for specified table.

* `SchemaInformation->listTableNames()` is now also cached,
  using new internal `buildTableNames()` method and avoid
  retrieving full schema information during the aggregation
  of the list.

* `SchemaInformation->getTableInfo(string $tableName)` is
  added to return the `TableInfo` for specified table using
  the `TableInfo` cache like other methods and sharing cache
  information.

* `introspectSchema()` and `introspectTable()` are removed
  from `SchemaInformation` in favour of the new DTO's and
  related method.

* A handfull usages in TYPO3 core code and tests are modifed
  to use the new methods and DTO's and replacing usage of
  removed methods.

Note that `SchemaInformation` is an internal structure and
making the aforementioned changes are not breaking based
on the TYPO3 breaking policy as long as internal usage is
adopted correctly, which is done and allows backporting
the change as base for mentioned reverted performance
change.

[1] https://review.typo3.org/c/Packages/TYPO3.CMS/+/76553
[2] https://review.typo3.org/c/Packages/TYPO3.CMS/+/79148
[3] https://review.typo3.org/c/Packages/TYPO3.CMS/+/90562
[4] https://review.typo3.org/c/Packages/TYPO3.CMS/+/90588

Review

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

Issues 5

Files 9

Review log 34

  1. Stefan Bürk commented on patch set 1 10/07/25, 13:02

    Cherry Picked from branch main.
  2. core-ci voted on patch set 1 V +1 10/07/25, 13:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86157

  3. Stefan Bürk voted on patch set 1 CR +2 V +2 10/07/25, 13:20

  4. Stefan Bürk merged patch set 2 10/07/25, 13:20