96120[BUGFIX] Use TCA default for columns created from TCA
Commit message
Test this change
Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch
- Check out patch set 6
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/20/96120/6 && git checkout FETCH_HEAD - Cherry-pick onto main
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/20/96120/6 && git cherry-pick FETCH_HEAD
Review
-
Code review CR 0 Needs a vote
-
Verified V -1 Blocked
- core-ci -1 CI
Merge conflicts 5
- main 97861[FEATURE] Add placeholder option for TCA selectSingle fields
- main 94753[FEATURE] New TCA type "coordinate"
- main 96543[WIP][POC][TASK] Write and read records by the same rules and rights
- main 92859[WIP][BUGFIX] Make MM tables language-aware and workspace-aware
- main 92589[TASK] Replace unneeded instanceof on xxx|null. Use a null check instead
Issues 2
Files 3
Review log 1824
-
Wolfgang Klinger uploaded patch set 1 09/28/26, 09:25
-
Mathias Brodala commented on patch set 1 09/28/26, 09:31
DefaultTcaSchema.php:1094Should we log a message if the default exceeds the field length? I can already imagine that this will be obscure and hard to debug. (Same goes for integer/dedimal default.) -
core-ci voted on patch set 1 V +1 09/28/26, 09:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/109401
-
Wolfgang Klinger uploaded patch set 2
V +109/28/26, 09:48 -
Wolfgang Klinger commented on patch set 1 09/28/26, 09:50
DefaultTcaSchema.php:568ReplyEach time, time() gives a new value. So the database analyzer would show a changed default for sys_file_metadata.content_creation_date and content_modification_date again and again. Core itself uses 'default' => time() there. Also, the default would be the time of the last cache flush, which is IMHO not a useful value for new rows (makes no sense?). I would keep datetime out of this change.DefaultTcaSchema.php:1094ReplyDone -
Mathias Brodala commented on patch set 2 09/28/26, 09:55
DefaultTcaSchema.php:568ReplyHm, not sure if I'm missing something but the 'default' => time() pattern can never meet the expectation. That TYPO3 itself uses it looks like a bug. As explained, a default like this will be fixed to the timestamp when the TCA was cached. So even if this pattern is basically wrong, the DB default should still follow the TCA default here: both will change once the TCA cache is flushed and rebuilt. IMO they should be the same. -
core-ci voted on patch set 2 V +1 09/28/26, 09:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/109403
-
Wolfgang Klinger commented on patch set 2 09/28/26, 09:57
DefaultTcaSchema.php:568ReplyI don't really have an opinion on this—who should decide? -
Mathias Brodala commented on patch set 2 09/28/26, 10:05
DefaultTcaSchema.php:568ReplyI've just asked in Slack about this, maybe someone else has an idea. -
Daniel Windloff commented on patch set 2 09/28/26, 15:49
Hey Wolfgang, thanks a lot for the patch. I understand the intention to establish consistency here. I don't have a 100% answer, but I have a few thoughts on the approach to schema creation and a possible alternative: - The basic idea at the time wasn't to create a database schema that always fits, but rather to offer a default schema. - Default values in TYPO3 are a topic in themselves. I've been following some changes for a while now to sort things out in the DataHandler for specific cases. Default values can be overridden in the TCA for the columns, per type, or via child records. They also depend on UsrTsConfig and PageTsConfig. In my view, there isn't really a "true" default value. Therefore, I find it difficult to define anything definitively, what is needed here. - The TcaSchemaApi doesn't offer default values for all columns. For this, I introduced the `hasDefaultValue` method. Generally, they can't be derived this way. Some default values are actually instructions to the DataHandler to generate the actual values (type: slug and uuid). - Deriving the schema from potentially changing values like `time()` don't feel right. With our deployments, this would result in a database schema change every time. A possible alternative, in my view, would be to take the other approach: using the database default value in the DataHandler if no value can be derived from the TCA/TSConfig etc. This way, one single value could also be defined consistently. Such an approach is already used for redirects (see https://git.typo3.org/typo3/typo3/-/blob/main/typo3/sysext/redirects/Classes/Service/SlugService.php?ref_type=heads#L386 ). If this would be an alternative for you, it could be added after the patch (https://review.typo3.org/c/Packages/TYPO3.CMS/+/90484 ), which first clarifies the default values handling in the DataHandler. For that patch, a prepatch is nessesary atm, that's why I can't finish it atm. What do you think about that approch? -
Wolfgang Klinger commented on patch set 2 09/28/26, 17:18
Reply
Thanks, I think your alternative would not help here, because it only changes the DataHandler. To me the two changes look complementary: this one for the database schema, yours for the DataHandler fallback after #90484. Or do you mean that the schema should stay as it is, and extensions that need a database default should declare the column in ext_tables.sql? -
Daniel Windloff commented on patch set 2 09/28/26, 18:21
Reply
Yes, my suggestion was to add the column to `ext_tables.sql` with the default value and use this value in DataHandler if no other value has been defined as default. This would lead to consistent default values, and the developer has a chance to set an overall default value without doubt. The generated default schema should stay as it is. -
Markus Klein uploaded patch set 3
V +110/28/26, 20:37 -
core-ci voted on patch set 3 V -1 10/28/26, 20:42 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112752
-
Markus Klein uploaded patch set 4
V -111/04/26, 13:48 -
core-ci voted on patch set 4 V -1 11/04/26, 13:56 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113278
-
Markus Klein uploaded patch set 5
V -111/04/26, 23:25 -
core-ci voted on patch set 5 V +1 11/04/26, 23:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113326
-
Markus Klein commented on patch set 5 11/05/26, 01:44
Add missing default for datetimeDefaultTcaSchema.php:568Replylet's include the default for SQL. Most datetime fields have a correct default value configured. using `time()` is at your own risk and yes, will change with every TCA cache flush. -
Markus Klein uploaded patch set 6
V +111/05/26, 08:20 -
Markus Klein commented on patch set 5 11/05/26, 08:20
Reply
Done -
Markus Klein commented on patch set 6 11/05/26, 08:23
Reply
I took the liberty to update this patch. I believe TCA should be the truth. If stuff is changed via TSconfig, one has to change the type / default in their ext_tables.sql -
core-ci voted on patch set 6 V -1 11/05/26, 08:42 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113361
-
Daniel Windloff commented on patch set 6 11/05/26, 20:01
Reply Unresolved
Since a clear default isn't always evident from a TCA perspective, I still don't think it's the best approch atm. However, I do agree with the fundamental approach of having TCA as a single source of truth.Generally, I've been wondering whether the default values set in this way shouldn't be validated (such as email address, color, country, etc.). Previously, all default values from the TCA were processed by the DataHandler and thus validated. Furthermore, these newly set default values might circumvent unique validations with meaningful values. I'm unsure about potential side effects.DefaultTcaSchema.php:669UnresolvedAs 0 is the default language I suggest keeping 0 here.DefaultTcaSchema.php:1096UnresolvedCheck for `$fieldType->hasDefaultValue()` is missing. A default value must not be set for every field type. If no default value has been set, the former default should be used.DefaultTcaSchema.php:1118UnresolvedCheck for $fieldType->hasDefaultValue() is missingDefaultTcaSchema.php:1131UnresolvedCheck for $fieldType->hasDefaultValue() is missingDefaultTcaSchema.php:1131Unresolvedthis should depend on `$fieldType->getScale()`
DefaultTcaSchema.php:568