90484[TASK] Drop stateful TCAdefaults in DataHandler
Commit message
Review
-
Code review CR +2 Done
- Benni Mack +2
- Josua Vogel +1
- Simon Schaufelberger +1
-
Verified V +2 Done
- Benni Mack +2
- Oliver Klee +1
- Josua Vogel +1
- Simon Schaufelberger +1
- core-ci +1 CI
Issues 3
Files 12
- typo3/sysext/backend/Classes/Hooks/DataHandlerContentElementRestrictionHook.php4+19 −2
- typo3/sysext/backend/Tests/Functional/Hooks/Fixtures/be_users.csv+1 −0
- typo3/sysext/backend/Tests/Functional/Hooks/Fixtures/pages.csv+2 −0
- typo3/sysext/backend/Tests/Functional/Hooks/DataHandlerContentElementRestrictionHookTest.php+83 −0
- typo3/sysext/core/Classes/DataHandling/DataHandler.php10+24 −183
- typo3/sysext/core/Classes/DataHandling/DefaultValuesResolver.phpnew+97 −0
- typo3/sysext/core/Documentation/Changelog/15.0/Important-107327-DataHandlerDefaultValueRelatedPropertyAndMethodsRemoved.rst4new+38 −0
- typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/DataSet/BackendUsersWithTcaDefaults.csvnew+6 −0
- typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/DefaultValuesTest.php14+156 −0
- typo3/sysext/core/Tests/Functional/DataHandling/ColumnsOverridesTest.php+1 −1
- typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php+6 −188
- typo3/sysext/core/Tests/Unit/DataHandling/DefaultValuesResolverTest.phpnew+244 −0
Review log 5176
Show 3151 earlier messages
-
Daniel Windloff uploaded patch set 1 08/25/25, 07:43
-
core-ci voted on patch set 1 V -1 08/25/25, 07:50 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83842
-
Benni Mack uploaded patch set 2
V -101/21/26, 15:53 -
core-ci voted on patch set 2 V -1 01/21/26, 16:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93963
-
Benni Mack uploaded patch set 3
V -101/23/26, 21:29 -
core-ci voted on patch set 3 V -1 01/23/26, 21:42 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94213
-
Garvin Hicking updated the commit message in patch set 4
V -101/23/26, 22:09 -
core-ci voted on patch set 4 V -1 01/23/26, 22:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94215
-
Daniel Windloff commented on patch set 4 V -1 02/04/26, 15:50
- Later added default values for each tca record type isn't respected. - Default handling for colpos -
Daniel Windloff commented on patch set 4 02/05/26, 09:02
On it -
Daniel Windloff uploaded patch set 5
V -102/05/26, 11:28 -
Daniel Windloff commented on patch set 5 V -1 02/05/26, 11:28
Still on it -
core-ci voted on patch set 5 V -1 02/05/26, 12:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95137
-
Daniel Windloff uploaded patch set 6
V -102/05/26, 12:24 -
core-ci voted on patch set 6 V -1 02/05/26, 12:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95141
-
Daniel Windloff uploaded patch set 7
V -102/05/26, 12:54 -
core-ci voted on patch set 7 V -1 02/05/26, 13:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95143
-
Daniel Windloff uploaded patch set 8
V -102/05/26, 13:37 -
core-ci voted on patch set 8 V -1 02/05/26, 13:45 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95150
-
core-ci voted on patch set 8 V +1 02/05/26, 13:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95150
-
Daniel Windloff uploaded patch set 9
V +102/05/26, 14:24 -
core-ci voted on patch set 9 V -1 02/05/26, 15:08 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95158
-
Daniel Windloff uploaded patch set 10
V -102/05/26, 15:19 -
core-ci voted on patch set 10 V -1 02/05/26, 15:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95171
-
Daniel Windloff uploaded patch set 11
V -102/06/26, 07:17 -
Daniel Windloff commented on patch set 11 02/06/26, 07:17
Reply
Done -
core-ci voted on patch set 11 V +1 02/06/26, 07:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95241
-
Benni Mack voted on patch set 11 CR +1 V +1 02/12/26, 16:47
-
Simon Schaufelberger commented on patch set 11 CR -1 02/12/26, 17:17
Important-107327-DataHandlerDefaultValueRelatedPropertyAndMethodsRemoved.rst:24format not correct. Must be `:php:xxx` and I also see more spaces in other places after the "-". Please also add an empty line before the list. -
Simon Schaufelberger commented on patch set 11 02/12/26, 17:19
DefaultValuesTest.php:237this is super hard to read. can we use empty lines after each assert?DefaultValuesTest.php:291remove empty line -
Daniel Windloff uploaded patch set 12
CR +1V +102/13/26, 08:13 -
Simon Schaufelberger commented on patch set 12 CR +1 02/13/26, 08:29
Important-107327-DataHandlerDefaultValueRelatedPropertyAndMethodsRemoved.rst:24ReplyDoneDefaultValuesTest.php:237ReplyDoneDefaultValuesTest.php:291ReplyDone -
core-ci voted on patch set 12 V +1 02/13/26, 08:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95806
-
Daniel Windloff rebased onto patch set 13
CR +1V +104/21/26, 15:07 -
core-ci voted on patch set 13 V +1 04/21/26, 15:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100661
-
Benni Mack updated the commit message in patch set 14
V +104/22/26, 07:21 -
Benni Mack commented on patch set 15 06/30/26, 21:57
Published edit on patch set 14. -
core-ci voted on patch set 15 V -1 06/30/26, 22:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104093
-
Daniel Windloff uploaded patch set 16
V -107/12/26, 07:39 -
Daniel Windloff uploaded patch set 17 07/12/26, 07:44
-
core-ci voted on patch set 16 V -1 07/12/26, 07:47 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104680
-
core-ci voted on patch set 17 V +1 07/12/26, 07:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104681
-
Simon Schaufelberger voted on patch set 17 CR +1 07/13/26, 10:38
-
Daniel Windloff rebased onto patch set 18
CR +1V +107/30/26, 08:14 -
core-ci voted on patch set 18 V +1 07/30/26, 08:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105671
-
Daniel Windloff uploaded patch set 19
V +108/15/26, 05:34 -
core-ci voted on patch set 19 V +1 08/15/26, 05:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106751
-
Stefan Bürk commented on patch set 19 08/15/26, 06:32
DataHandlerContentElementRestrictionHook.php:100That's pretty use-less now - the result is the $incomingFieldArray every time. Not applying default values here anymore - not verified if that's correct here - makes the complete `else {}` branch obsolete and can be simply dropped. Furter it would allow to negate the first if condition in the loop and do a early return and unnest the block one-level and making that part a little slimmer. -
Daniel Windloff commented on patch set 19 08/15/26, 07:34
DataHandlerContentElementRestrictionHook.php:100ReplyAs far as I remember, the situation is: The default values never applied properly for new records during this check. Only default values from UserTS have been evaluated before this hook has been initiated before my change, leaving the majority of sources of default values unattended. As I think this was and is a bug, I marked it with a todo as it should be resolved later. -
Daniel Windloff uploaded patch set 20
V +109/04/26, 06:32 -
core-ci voted on patch set 20 V -1 09/04/26, 06:44 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107802
-
Daniel Windloff uploaded patch set 21
V -109/04/26, 06:47 -
core-ci voted on patch set 21 V +1 09/04/26, 07:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107810
-
Stefan Bürk commented on patch set 19 09/15/26, 08:30
DataHandlerContentElementRestrictionHook.php:100ReplyI checked this again and more closely now. This is more than dead code, previous to this change `DataHandler::start()` filled in the `$defaultValues` from UserTsConfig **before** `process_datamap()` calls the `processDatamap_beforStart` hooks. That means, that these hooks see a UserTsConfig `TCAdefaults.tt_content.CType`/`colPos`, which is no longer the case with this change. I suggest that we should resolve `CType` and `colPos` here in the same order `DataHandler` uses: incoming value, then PageTsConfig of the target page, then the UserTsConfig and than the TCA defaults) instead of keeping the `@todo`. That would closes both cases and makes `array_merge([], ...)` vanish here. This should also be covered with a functional test.DataHandler.php:524The order listed here differs from the old one. Before, a type-specific value from *any* source beat any field-level value (user TS `types.1` won over page TS field-level). Now page TS field-level wins. That matches FormEngine (`DatabaseRowInitializeNew`) and `Feature-107281`, so I think it is correct. But it is a behaviour change for integrators. Could you mention it in the commit message? `defaultValueFallback` fails on the parent commit on exactly that step.DataHandler.php:526The leak described in #107327, where page TSconfig `TCAdefaults` of one record are merged into `$this->defaultValues` and then applied to all records processed afterwards, is not new. It exists since #89211 (2020) and I could reproduce it on 12.4, 13.4, 14.3 and main. Because this patch removes `@internal` API, it can not be backported to fix that. So I extracted the plain bugfix into its own issue and change, without any API change: * Forge: https://forge.typo3.org/issues/110705 * Gerrit: https://review.typo3.org/c/Packages/TYPO3.CMS/+/95839 (main), with backports 95840 (14.3) and 95841 (13.4) Could you rebase this change onto 95839 once it is merged, so the refactoring sits on top of the fix rather than being the fix? The conflict is limited to `applyDefaultsForFieldArray()`, which this patch rewrites anyway, and to `DefaultValuesTest`.DataHandler.php:546The type falls back to the TCA default of the type field, but a `TCAdefaults.<table>.<typeField>` from page/user TS is ignored. With `TCAdefaults.pages.doktype = 254` and `description.types.1 = standard` / `description.types.254 = folder`, the page is created as a folder but gets `description = standard`, together with the `columnsOverrides` defaults of type 1. This was already the case before (through the early `newFieldArray()`), so it does not block. But taking the type from the first source that defines an existing type, in the same order as the values ``` incoming -> page TS -> user TS -> TCA ``` is only a few lines and keeps type and values consistent. It also removes the duplicated `$schema->getField($schema->getSubSchemaTypeInformation()->getFieldName())`.DataHandler.php:551This drops global PageTSConfig (`EXT:*/Configuration/page.tsconfig`) for everything created on `pid 0`. Before, `getPagesTsconfig(0)` was used instead and FormEngine applied it for pid 0 too. My assumption here is, that this guard has been added here for unit tests failing with `NoSuchCacheException: runtime` - or am I wrong here ? What about passing the resolved TCAdefaults into the method instead, for example: ``` $this->applyDefaultsForFieldArray( $table, BackendUtility::getPagesTSconfig($tscPID)['TCAdefaults.] ?? [], $fieldArray, $incomingFieldArray, ); ``` What do you think ?DataHandler.php:576Small nit-pick, the comments sit at the end of the *previous* branch, and every condition repeats `$schema->getName() . '.'` / `$field->getName()` / `$subschema->getField(...)`. The sub-schema line is about 300 characters). Locals such as `$pageTsDefaults = $pageTsConfig['TCAdefaults.'][$table . '.'] ?? []`, `$fieldName` and `$subSchemaField` make the chain readable without the comments. `$schema->getName()` is `$table` anyway.Important-107327-DataHandlerDefaultValueRelatedPropertyAndMethodsRemoved.rst:18`:php\`DataHandler->defaultValues\`` — missing colon after `php`, the role does not render.Important-107327-DataHandlerDefaultValueRelatedPropertyAndMethodsRemoved.rst:20`applyDefaultsForFieldArray` is protected, so there is no need to point readers to it. "Moved to `process_datamap()`" does not say much either. Maybe describe what changed instead: defaults are now resolved per new record, without keeping state in the DataHandler instance. Also mention that the removed members were `@internal`. The leak between records is fixed separately (#110705 / 95839), so this changelog only needs to cover the removed internals.DefaultValuesTest.php:16795839 adds a test for the same scenario `defaultValuesFromPageTSconfigAreNotAppliedToRecordsOnOtherPages`, content elements on two sibling pages in one DataHandler run. After rebasing onto it, this test can either be dropped or kept as the `pages` variant, including the sub-page case.DefaultValuesTest.php:176Small nit-pick: empty line inside the array.DefaultValuesTest.php:192`$this->get(DataHandler::class)` rather than `GeneralUtility::makeInstance()` in new functional tests.DefaultValuesTest.php:210Seven scenarios in one test. A data provider (or one test per source) would name the failing step. The test name does not say what is expected either. Typos in the comments: `UsrTSConfig`, `UseTSConfig`, `specifc`.DefaultValuesTest.php:272`@todo` (lowercase) is the core convention. Flushing only the runtime cache (`$this->get('cache.runtime')->flush()`) is enough: `getPagesTSconfig()` caches per pid there, and `modifyRecord()` does not invalidate it.be_users_admin.csv:10This fixture is shared by 31 test files. Could the scenario users go into a DataSet next to `DefaultValuesTest` instead? User 3 also reuses the username `foo`, and there is a trailing blank line. -
Stefan Bürk commented on patch set 21 CR -1 13 comments 09/15/26, 08:30
Thanks for sticking with this, the stateless per-record resolution is the right direction. I found two regressions and wrote tests for them: 1. The content element restriction hook no longer sees user TS `CType`/`colPos` defaults, so a disallowed CType can be stored. It was rejected previously. 2. Records on pid 0 no longer get global page TSconfig `TCAdefaults` because of the `$pageId !== 0` guard. Details and a suggested approach are in the inline comments. I have the functional tests and a small patch ready if you want them. Minor: changelog RST role, fixture, test naming, commit subject. About the leak itself: it exists since 2020 on every branch, and this patch can not be backported because it removes API. So I extracted a minimal bugfix without API changes: forge #110705, change https://review.typo3.org/c/Packages/TYPO3.CMS/+/95839 for main, with the backports 95840 (14.3) and 95841 (13.4). Please rebase this change onto it later, once it is merged, and treat this one as the refactoring on top of it. -
Stefan Bürk commented on patch set 21 09/15/26, 08:52
On it .. stay tuned .. -
Stefan Bürk uploaded patch set 22
CR -1V +109/15/26, 09:05 -
core-ci voted on patch set 22 V +1 09/15/26, 09:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108599
-
Stefan Bürk commented on patch set 21 09/15/26, 09:29
DataHandler.php:524ReplyDone in patch set 22: the precedence change is mentioned in the commit message and in the changelog.DataHandler.php:526ReplyThe isolated fix is https://review.typo3.org/c/Packages/TYPO3.CMS/+/95839 (forge #110705, backports 95840 and 95841). Patch set 22 is rebased on top of it, so this change is the refactoring only now.DataHandler.php:546ReplyDone in patch set 22. The record type is taken from the first source defining an existing type: incoming data, page TSconfig, user TSconfig, TCA default. A type pointing to a field of a related record (like uid_local:type) is not resolved from the local value anymore. Covered by DefaultValuesResolverTest and typeSpecificDefaultsUseRecordTypeDefinedByTsConfigDefault.DataHandler.php:551ReplyConfirmed: without the guard the unit tests failed with "NoSuchCacheException: runtime". Done in patch set 22: the caller passes BackendUtility::getPagesTSconfig($tscPID)['TCAdefaults.'] into applyDefaultsForFieldArray(), the guard is gone, and defaultValuesFromGlobalPageTsConfigAreAppliedForRecordsOnRootLevel covers records on pid 0.DataHandler.php:576ReplyDone in patch set 22. The resolution moved into DefaultValuesResolver, using $pageTsDefaults, $userTsDefaults, $fieldName and $subSchemaField locals, without the misplaced comments.Important-107327-DataHandlerDefaultValueRelatedPropertyAndMethodsRemoved.rst:18ReplyFixed in patch set 22.Important-107327-DataHandlerDefaultValueRelatedPropertyAndMethodsRemoved.rst:20ReplyDone in patch set 22. The description covers the stateless resolution per record, the behaviour changes and the removed internal members, and no longer points to protected methods.DefaultValuesTest.php:167ReplyKept as the pages variant including the sub page case, renamed to defaultValuesFromPageTSconfigAreAppliedToSubPagesOnly, next to the test from 95839.DefaultValuesTest.php:176ReplyFixed in patch set 22.DefaultValuesTest.php:192ReplyDone in patch set 22.DefaultValuesTest.php:210ReplyDone in patch set 22: replaced by defaultValuesAreTakenFromSourceWithHighestPrecedence, with one named data provider case per source. The typos are gone with it.DefaultValuesTest.php:272ReplyDone in patch set 22. It turned out the flush is not needed at all, the tests pass without it, so the flush and the @TODO are both removed.be_users_admin.csv:10ReplyDone in patch set 22. The shared fixture is untouched, the scenario users live in DataSet/BackendUsersWithTcaDefaults.csv with unique user names. -
Stefan Bürk commented on patch set 19 09/15/26, 09:29
DataHandlerContentElementRestrictionHook.php:100ReplyDone in patch set 22. For new records the hook now resolves the default values with the new DefaultValuesResolver, the same service DataHandler uses: incoming value, page TSconfig of the target page, user TSconfig, then TCA, including type-specific values. So leaving out CType or colPos no longer bypasses the restriction. The @todo lines and the array_merge([], ...) are gone, and DataHandlerContentElementRestrictionHookTest covers allowed and rejected cases. -
Stefan Bürk uploaded patch set 23
V +109/15/26, 10:34 -
core-ci voted on patch set 23 V +1 09/15/26, 10:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108612
-
Benni Mack wrote 10/16/26, 07:45
Topic set to DataHandler -
Daniel Windloff uploaded patch set 24
V +110/16/26, 11:44 -
core-ci voted on patch set 24 V +1 10/16/26, 11:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111353
-
Daniel Windloff marked it ready for review 10/16/26, 11:54
-
Oliver Klee voted on patch set 24 V +1 10/17/26, 17:10
-
Benni Mack commented on patch set 24 10/22/26, 15:52
Reply
Done -
Daniel Windloff rebased onto patch set 25
V +110/22/26, 15:52 -
core-ci voted on patch set 25 V +1 10/22/26, 16:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112141
-
Oliver Klee voted on patch set 25 V +1 10/22/26, 17:45
-
Josua Vogel voted on patch set 25 CR +1 10/22/26, 19:30
-
Josua Vogel voted on patch set 25 V +1 10/22/26, 19:44
-
Simon Schaufelberger voted on patch set 25 CR +1 V +1 10/22/26, 20:58
-
Benni Mack voted on patch set 25 CR +2 V +2 10/23/26, 07:09
-
Benni Mack merged patch set 26 10/23/26, 07:09