Review main Merged

63965[TASK] Move EXT:form inline JS from template to controller

Claus Due CR +2 V +2 Easy +24 −18 updated 10/22/21, 20:51

Commit message

Allows compatibility with Fluid 3.x.

The change is necessary because Fluid 3.x moves away from regular
expression to detect Fluid syntax, while also allowing more detailed
customisations of what can be written as inline syntax. The result
is that the JSON object notation gets seen as Fluid syntax. Even if
Fluid 3.x natively was more permissive about such embedding, combining
it with calls to Fluid ViewHelpers would still present problems (when
is a curly brace JSON and when is it Fluid? Do we process Fluid tag
notation only inside strings in that JSON? How aware should Fluid be,
not just of JSON but potentially also embedded XML? And can we accept
a considerable increase in Fluid's internal complexity to handle these
edge cases for any conceivable embedding strategy?). In order to avoid
this complexity, Fluid 3.x pragma has been to make it intentionally
more naive, at the cost of potentially detecting syntax that in 2.x
would not be detected as Fluid syntax.

As a side note: there *is* a standard way to tell Fluid "this syntax
isn't Fluid" - by prefixing curly brace statements with a backslash -
but this approach is not compatible with Fluid 2.x which would simply
output the backslash, resulting in invalid JSON syntax.

Essentially, while we keep support for Fluid 2.x we are slightly more
constrained in what we can choose to embed in Fluid, because whatever
we choose to embed, must be compatible with both versions.

And though there *are* certain ways we could accommodate JSON-in-Fluid,
none of them are straight-forward and may in the end only encourage
less than ideal practices (such as embedding script tags with Fluid
being used to build variables - which is something that ideally should
be handled in a controller, and in TYPO3 context, integrated via the
PageRenderer instead of appearing at arbitrary places in DOM).

So even though much more detailed explanations/workarounds are possible,
TYPO3 CMS should constitute a best-practice reference and be as
compatible as we possibly can - which in this case means not embedding
Fluid-processed JSON in templates, but rather use the controller and
PageRenderer to do such embedding.

A similar change was done to embed the "goTo_altDoc" JS function in
the page module, to pass the entire function as Fluid variable instead
of passing only the function body as variable. PageRenderer was not
used for that, since the function was rendered as part of a modal which
does not use PageRenderer for output - since PageRenderer is available
in context of the Form module, it is preferable to use that strategy.

Review

  • Code review CR +2 Done
    • waldhacker +2
    • Björn Jacob +1
  • Verified V +2 Done
    • waldhacker +2
    • Björn Jacob +1
    • core-ci +1 CI

Issues 1

Files 4

Review log 1317

  1. Claus Due uploaded patch set 1 03/28/20, 11:18

  2. TYPO3com voted on patch set 1 V +1 03/28/20, 11:30 Completed build in 11m 23s on Sat, 28 Mar, 11:30 AM Test Summary: 73044 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1891

  3. Georg Ringer commented on patch set 1 03/28/20, 18:22

    and what with 9.5?
  4. Benjamin Franzke commented on patch set 1 CR -1 05/12/20, 20:02

    FormEditor.html:28

    Can we describe the reason why this code is Fluid 3.x incompatible in the commit message? Is it because of nested curly braces? This smells like something that Fluid 3.x should support. Inline javascript is of course discouraged, still, the templating should be able to output this. If it's really about curly braces then some sort of escaping would be needed.
  5. Claus Due commented on patch set 1 05/13/20, 07:32

    FormEditor.html:28 Reply Unresolved

    Bottom line is, if you want this to work with Fluid 2.x and 3.x at the same time, then this is the way it has to happen. Fluid 3.x has a way to escape things (prefixing the curly braces with a backslash) but that doesn't work the same on 2.x. And 2.x of course has its own way which is centered around breaking regexp detection.
  6. Claus Due updated the commit message in patch set 2 06/02/20, 12:03

  7. TYPO3com voted on patch set 2 V +1 06/02/20, 12:14 Completed build in 10m 52s on Tue, 2 Jun, 12:14 PM Test Summary: 72842 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3743

  8. Sascha Egerer commented on patch set 2 CR +1 05/11/21, 05:07

    Would be very cool to get that merged
  9. waldhacker uploaded patch set 3 08/11/21, 09:48

  10. core-ci voted on patch set 3 V -1 08/11/21, 10:10 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14568

  11. waldhacker uploaded patch set 4 08/11/21, 10:20

  12. core-ci voted on patch set 4 V +1 08/11/21, 10:34 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14572

  13. waldhacker voted on patch set 4 V +1 CR +1 08/11/21, 10:36

  14. Björn Jacob voted on patch set 4 V +1 CR +1 08/11/21, 10:50

  15. waldhacker voted on patch set 4 V +2 CR +2 08/11/21, 10:55

  16. waldhacker merged patch set 5 08/11/21, 10:56

  17. Oliver Hader commented on patch set 5 10/22/21, 20:51

    Just stumbled over this: Just WOW!