96341[BUGFIX] Validation of TCA column type "color"
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 4
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/41/96341/4 && git checkout FETCH_HEAD - Cherry-pick onto main
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/41/96341/4 && git cherry-pick FETCH_HEAD
Review
-
Code review CR 0 Needs a vote
-
Verified V 0 Needs a vote
- core-ci +1 CI
Merge conflicts 24
- main 97304[WIP][BUGFIX] Render the record form from unsaved values
- main 96745[BUGFIX] DataHandler: Streamline `null` handling
- main 97560[TASK] Find subpages with one query when copying and deleting pages
- main 97603[TASK] Introduce RecordTypeResolver and deprecate getTCAtypeValue()
- main 92705[BUGFIX] Only offer translations of records the user may localize
- main 93819[WIP][BUGFIX] Guard translated tt_content free-mode moves
- main 94753[FEATURE] New TCA type "coordinate"
- main 97122[TASK] Restore time zones after date tests
- main 95105[TASK] Apply PHP code simplifications
- main 96543[WIP][POC][TASK] Write and read records by the same rules and rights
- main 74781[FEATURE] Introduce new slug builders for records and string
- main 96829[!!!][BUGFIX] Restore deleted records by their deletion operation
- main 92859[WIP][BUGFIX] Make MM tables language-aware and workspace-aware
- main 96344[BUGFIX] Keep live and foreign MM rows when creating a version
- main 95145[TASK] Migrate LanguageService->sL() labels to new domain syntax
- main 95343[FEATURE] Add `adminOnly` for TCA columns
- main 95638[TASK] Extend FieldValidationService to more TCA field types
- main 95639[TASK] Extract a read-only UniquenessChecker from DataHandler
- main 95637[TASK] Introduce FieldValidationService for TCA field validation
- main 93407[TASK] Modernize `RecordHistoryStore`
- main 92214[TASK] Introduce generic permission sets for accessing data
- main 85574[WIP][FEATURE] Language-aware slugs and slug normalizer API
- main 87719[WIP][BUGFIX] Mitigate missing column in cached schema information
- main 86432[WIP][TASK] Cache flexform schema during TCA schema creation
Issues 1
Files 7
- typo3/sysext/core/Classes/DataHandling/ColorService.phpnew+241 −0
- typo3/sysext/core/Classes/DataHandling/DataHandler.php4+20 −3
- typo3/sysext/core/Documentation/Changelog/15.0/Important-110901-ValidationAndTransformationForColumnTypeColor.rstnew+51 −0
- typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/ColorValidationTest.phpnew+253 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_datahandler/Configuration/TCA/tx_testdatahandler_element_color.phpnew+53 −0
- typo3/sysext/core/Tests/Unit/DataHandling/ColorServiceTest.phpnew+363 −0
- typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php+6 −0
Review log 1115
-
Daniel Windloff uploaded patch set 1 10/03/26, 05:26
-
core-ci voted on patch set 1 V -1 10/03/26, 05:34 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110021
-
Daniel Windloff uploaded patch set 2
V -110/03/26, 05:44 -
core-ci voted on patch set 2 V +1 10/03/26, 05:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110023
-
Georg Ringer commented on patch set 2 10/03/26, 18:43
why transforming short => long + name => hex? don't see a reason for that -
Daniel Windloff commented on patch set 2 10/04/26, 06:30
Reply
Converting CSS color names to hex values makes sense because the database field has a limited length. Using the long hex format allows the length of the resulting string to be precisely determined. Converting from the short to the long hex format serves only to ensure consistency. This could also be achieved through two additional validation steps and a different default value for the default opacity. While I prefer a consistent format for the entries, I see no technical necessity for it.Reply
For transforming css names to hex is useful, as the default length of the datbase row is limited. Using the long hex format wie exacly know the resulting string length. The transformation from short to long hex is just for consistency. It can be replaced by two more validations and a diffrent default opacity as well. I usually prefer the same kind of entry, but it's no tecnical need I see. -
Benni Mack wrote 10/16/26, 07:44
Topic set to DataHandler -
Benjamin Franzke commented on patch set 2 10/23/26, 14:26
DataHandler.php:1599Why should we map named CSS colors, that's a new feature, right? Why do you think that we need such a feature? -
Daniel Windloff commented on patch set 2 10/23/26, 15:01
DataHandler.php:1599ReplyI took a look at the color picker in FormEngine. When I specified "black" or "yellow," for example, the corresponding color was displayed and saved correctly. However, the persistence layer assumed the HEX format, but did not enforced it. In practice, only a limited set of color values depending on the string length could be saved. Adding a validation using the HEX format without any replacement of color names would reject those color values that were previously considered valid regarding the feedback from the color picker. That is why I thought this replacement is needed. -
Daniel Windloff uploaded patch set 3
V +110/24/26, 05:01 -
core-ci voted on patch set 3 V +1 10/24/26, 05:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112389
-
Daniel Windloff uploaded patch set 4
V +110/26/26, 03:49 -
core-ci voted on patch set 4 V +1 10/26/26, 03:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112551
-
Benjamin Franzke commented on patch set 4 11/06/26, 14:25
DataHandler.php:1599ReplyThanks Daniel, fair point that the picker accepts "red" today. I'd rather not keep a color table in PHP though: the browser knows all CSS colors, so the picker could convert them on change and DataHandler would only accept hex. I've sketched that locally (it also fixes clearing the field, which PS4 broke, and rejects overlong input instead of truncating it). Bigger question, though: do we want to limit this to hex at all? Hex is sRGB only, so oklch()/display-p3 colors can't be stored. That limit already comes from the varchar(7/9) column, so lifting it would be a separate change. Should I push the sketch as a new patch set, or do you want to take it from here? -
Daniel Windloff commented on patch set 4 11/06/26, 17:54
DataHandler.php:1599Reply UnresolvedThanks for your reply. I can not say whether the restriction to HEX should remain or not. My goal here was simply to add server-side validation, which I felt was missing in DataHandler. You are welcome to submit a new patch set featuring the alternative approach.