Review main Abandoned

83646[WIP][BUGFIX] Evaluate TCEFORM TSconfig for flexform overrides

Garvin Hicking CR 0 V 0 Hard +559 −1 updated 12/29/24, 23:52

Commit message

-- TO BE ABANDONED IN FAVOR OF https://review.typo3.org/c/Packages/TYPO3.CMS/+/83728 --

Changing a flexform field `config` data with TCEFORM TSconfig
was not evaluated.

This patch parses the special type `flex` in
`FormEngineUtility::overrideFieldConf` with a method implemented
in `FlexFormTools` of the same name. That new code was moved there
to ease maintenance of flexform-specific code.

It works quite similar to the TCEFORM config change of base-level
fields like `tt_content.header`, and also only allows to
change the keys listed in `$allowOverrideMatrix`.

This matrix now also allows to alter the `enableRichtext` state
of `type=text` configs.

To see this working, take a flexform plus a TSconfig TCEFORM override,
like the one provided by `EXT:styleguide` (`Simple.xml`). Enter this as
TSconfig on a page where a "Form engine - flex" styleguide plugin
was placed:

```
TCEFORM.tx_styleguide_flex.flex_file_1.default.sDEF.input_1 {
  label = Override Label
  config {
    max = 30
    size = 5
  }
}
```

This had no effect previously, and is now properly evaluated.

A test has been added to verify this behavior on a simple DS
with type=input, and ensuring no TCA modifications are made
with wrong TSconfig or mismatching TCA.

The documentation already listed this as a working example:
https://docs.typo3.org/m/typo3/reference-tsconfig/main/
en-us/PageTsconfig/TceForm.html#config

Review

  • Code review CR 0
  • Verified V 0

Issues 4

Files 3

Review log 2434

Show 59 earlier messages
  1. Garvin Hicking uploaded patch set 1 04/04/24, 11:23

  2. core-ci voted on patch set 1 V -1 04/04/24, 11:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55330

  3. Garvin Hicking uploaded patch set 2 V -1 04/04/24, 11:31

    cgl
  4. core-ci voted on patch set 2 V +1 04/04/24, 11:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55331

  5. Garvin Hicking uploaded patch set 3 V +1 04/04/24, 12:22

    adjust multiline comments
  6. core-ci voted on patch set 3 V -1 04/04/24, 12:26 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55334

  7. Garvin Hicking uploaded patch set 4 V -1 04/04/24, 12:46

    cgl part deux
  8. core-ci voted on patch set 4 V +1 04/04/24, 12:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55335

  9. Oli Bartsch commented on patch set 4 04/04/24, 13:41

    This patch reads quite good! However, please let's cover this with tests.
  1. Garvin Hicking commented on patch set 4 04/04/24, 14:33

    Reply

    If it has a chance of implementation I'll happily try to! Could you give me a hint on how to test this? Do I need to fake an event listener to check the data? I'm a bit clueless about the implications, but if there's something similar I can use as a template...?
  2. Garvin Hicking uploaded patch set 5 V +1 04/04/24, 16:55

    Add test
  3. Garvin Hicking uploaded patch set 6 04/04/24, 16:56

    cgl
  4. Garvin Hicking commented on patch set 6 04/04/24, 16:59

    Reply

    I've added a simple test `overrideFieldConfWorksFromTSConfigOverrideOnFlexform` to the existing `FlexFormToolsTest`, which operates on a simple datastructure, parses that to TCA, adds TSConfig to override that, and verifies the expected TCA matches the operation. Please let me know if there is anything else I can test. It would be a lot of permutations to test every possible TCA key and it's allowOverrideMatrix correspondance - so I hope one representative key should do.
  5. core-ci voted on patch set 6 V +1 04/04/24, 17:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55342

  6. core-ci voted on patch set 5 V -1 04/04/24, 17:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55341

  7. Nikita Hovratov commented on patch set 6 04/04/24, 18:11

    Please add a new "Related" entry for each issue, rather than comma separated.
  8. Nikita Hovratov commented on patch set 6 04/04/24, 18:17

    FlexFormTools.php:739

    Not sure if this is the right place for the method. Lolli worked hard to reduce this service class to the few methods, which are left. A static method seems out of place here. Let's either put it inside FormEngineUtility (the only place where this is used) or create a new internal utility class.
  9. Garvin Hicking commented on patch set 6 04/04/24, 19:18

    FlexFormTools.php:739 Reply

    I was afraid that exactly @lolli@schwarzbu.ch refactoring flexformtools more would maybe miss such a utility class then. His future refactoring might then move this to a better fit place/structure? Introducing another flexform utility feels wrong to me, better to have flexform operations at a single place. It's quite easy to move anywhere, so I'd be quite happy for instructions, maybe I can summon Lolli on this for ideas: lollijuice, lollyjuice, lollyjuice?
  10. Garvin Hicking uploaded patch set 7 V +1 04/05/24, 07:27

    Improved tests and fixed one depth level
  11. Garvin Hicking uploaded patch set 8 04/05/24, 07:28

    cgl
  12. Garvin Hicking commented on patch set 8 04/05/24, 07:31

    Reply

    I've added some more tests operating on invalid TSconfig and TCA, and actually with that found out I had one level of "[default]" too much in the TSconfig array. Well worth the tests, sorry for not adding it directly. :-)

    Reply

    Done
  13. core-ci voted on patch set 7 V -1 04/05/24, 07:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55370

  14. core-ci voted on patch set 8 V +1 04/05/24, 07:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55371

  15. Garvin Hicking uploaded patch set 9 V +1 04/05/24, 08:21

    Default datastructureIdentifier was actually needed
  16. core-ci voted on patch set 9 V +1 04/05/24, 08:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55372

  17. Garvin Hicking commented on patch set 9 04/05/24, 08:27

    Reply

    Actually that "default" was needed due to it being the dataStructureKey that needs to match. I found my mistake on this and now it's (hopefully) properly checked in the execution and tests.
  18. Christian Kuhn commented on patch set 9 04/09/24, 11:29

    FlexFormTools.php:739 Reply

    first reply: currently unsure. but i especially dislike the introduced dependency from core to backend through FormEngineUtility::getAllowOverrideMatrix();

    FlexFormTools.php:783

    this, together with json_decode($fieldConfig['dataStructureIdentifier']) is an api misuse: the ds-identifier is an internal structure that is only understood and should only be parsed by the above methods, see their comments. actually formEngine should have the resolved DS at this point, if not, the call to the overrides needs to be relocated in formEngine somehow. needs more investigation.
  19. Christian Kuhn commented on patch set 9 CR -1 04/09/24, 11:30

    -1 for now, needs a bit of investigation.
  20. Garvin Hicking commented on patch set 9 04/09/24, 11:58

    FlexFormTools.php:739 Reply Unresolved

    We could transport the whole override matrix as a parameter to the FlexFormTools::overrideFieldconf. Or, if we decide to not keep the new code in FlexFormTools, but rather move it to FormEngineUtility, we can of course just use the local property then and don't even need to carry it across. I'm totally open on where to move the functionality of this, I have no clear preference.

    FlexFormTools.php:783 Reply

    Let me try to explain the reasoning behind this a bit: The large array iteration is performed on the TCEForm array. That TCEform references the "dataStructureKey" (for tt_content that's "pi_flexform" as a name, for the styleguide example and others it's "default"). To properly iterate the TCEform array to find the columns to be overriden from the datastructure, I need that key. The key is contained in the large JSON chunk, and I only need the `dataStructureKey` from it. The whole DS source is irrelevant from what I can see. Since it is already part of what is getting passed as $fieldConfig to FormEngineUtility::overrideFieldConf() in first place. So at this point I don't really care about the contents of the DS, but just the key, for the TCEform lookup. The method `parseDataStructureByIdentifier` (which performs the json_decode) only returns $dataStructure, and that array is missing the datastructureKey; so I sadly cannot utilize that method at all. Instead, we could refactor the "json_decode" call inside that method to be its own method, and let `FlexFormTools::overrideFieldConf` access that method. To do that, no longer could FlexForms be called statically, but would need a full makeInstance call with DI, and the new method wouldn't do more than json_decode() (probably it shouldn't even throw an error, and just not apply modifications from TCEForm to TCA ). So that feels like very much of legwork (and possible performance) just to get the dataStructureKey for further operation, which would be retrievable with that one line of json_decode? Any other type than "tca" for it could be ignored, since this only applies to the TCA-Rendering of FormEngine. Happy to hear your thoughts on this, and I'll provide an implementation if you can map me a way through the goalposts.
  21. Garvin Hicking commented on patch set 9 04/09/24, 12:25

    FormEngineUtility.php:58 Unresolved

    Note to self after feedback by Christian: Allowing this is problematic. DataHandler will (probably?) not perform data cleanup methods on a field if it is changed as an override instead of a native definition, because DataHandler will not parse TCEForm overrides here (probably?). Test & make sure that this is still the case, or if DataHandler has some secret sauce to perform sanitizing and processing after all. Remove this again and add a code comment about why not every override is allowed (reference to DataHandler). Cleanup references to 'richText' in commit message and tests.
  22. Stefan Bürk commented on patch set 9 04/10/24, 11:53

    FlexFormTools.php:783 Reply Unresolved

  23. Garvin Hicking updated the commit message in patch set 10 CR -1 V +1 09/18/24, 09:19

  24. core-ci voted on patch set 10 V -1 09/18/24, 09:56 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66111

  25. Garvin Hicking abandoned the change 12/29/24, 23:52