Review main Merged

75178[FEATURE] Revamp TypoScript Template Analyzer

Christian Kuhn CR +2 V +2 Expert +1220 −302 updated 07/16/22, 19:46

Commit message

This establishes the first usage of the new TypoScript
parser and leverages some of its improved functionality:
A rewrite of the template analyzer backend module based
on the new parser gives a series of new features.

Most importantly, the TypoScript include tree now
resolves all @import and INCLUDE_TYPOSCRIPT includes
and shows them as single nodes within the include tree.

Additionally, the template analyzer is now condition
aware: It finds all conditions within the include
tree and allows to simulate include tree restrictions
based on condition verdicts.

The major outcome of this is that the analyzer now
shows in-depth includes and allows much more fine
grained analysis of all includes that play a role
on a single page.

Known issue: t3editor (codemirror) sometimes fails to
initialize properly to render TypoScript source when
clicking a node in the include tree. This is probably
some JavaScript load-order race condition and will be
tackled with a dedicated patch.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Stefan Bürk +1
    • Andreas Kienast +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Stefan Bürk +1
    • Andreas Kienast +1
    • core-ci +1 CI

Issues 2

Files 22

Show 2 more files

Review log 3345

Show 1320 earlier messages
  1. Christian Kuhn uploaded patch set 1 07/14/22, 11:47

  2. core-ci voted on patch set 1 V +1 07/14/22, 11:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29140

  3. Christian Kuhn uploaded patch set 2 07/14/22, 11:58

  4. core-ci voted on patch set 2 V +1 07/14/22, 12:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29141

  5. Christian Kuhn uploaded patch set 3 07/14/22, 13:33

  6. core-ci voted on patch set 3 V +1 07/14/22, 13:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29148

  7. Christian Kuhn uploaded patch set 4 07/14/22, 15:23

  8. core-ci voted on patch set 4 V +1 07/14/22, 15:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29155

  9. Christian Kuhn uploaded patch set 5 07/14/22, 15:40

  10. core-ci voted on patch set 5 V +1 07/14/22, 15:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29157

  11. Benni Mack commented on patch set 5 V +1 07/14/22, 16:25

    Just tested this patch. There are some quirks UI-wise still (collapsable options is a bad idea IMHO), also some "lines" along the inclusions are not 100% complete. In addition, I think we should explain the "Types" of includes and what that means (via tooltip or whatever). Also noticed the quirks around the expanding / collapsing part. However, I'm pretty sure that Benjamin Kott could fix them separately, as they are visual work.
  12. Oli Bartsch commented on patch set 5 07/14/22, 17:40

    Just had a short look because I'm currently not able to access the module. I get the following exception: (1/1) TypeError sha1(): Argument #1 ($string) must be of type string, array given in /var/www/html/typo3/sysext/core/Classes/TypoScript/IncludeTree/TreeBuilder.php line 523 It looks like a setting in my site config triggers this. I define the following there: settings: mySetting: 3

    TemplateAnalyzerController.php:50

    Seems to be unused.

    TemplateAnalyzerController.php:58

    We might need this line. Seems that it was not called before, due to the if clause which from reading always evaluated to FALSE. However, this might be a bug, because module data is never stored for the user. Will investigate as soon as I'm able to access the module.

    TemplateAnalyzerController.php:81

    In case we do no longer use this, we should remove it from the allowed module data.

    FineDiffViewHelper.php:2

    I think all those viewhelpers should be marked as @internal.

    IsInstanceOfViewHelper.php:36

    I assume there is no other way of handling this in e.g. the controller (or any other class, where business logic takes place)?

    AnalyzerTreePanel.html:47

    Could we get rid of those empty tags? According to https://developer.mozilla.org/en-US/docs/Glossary/Empty_element, <td> is not allowed as empty element.
  13. Stefan Bürk commented on patch set 5 07/14/22, 22:25

    Reply

    Seems that was a overlook when the new parser/tree build was added. If no "site config settings" are set, there is a early return. This was not tested as it seems. Building the hash should be: ``` $identifier = 'site-constants-' . sha1(serialize($siteSettings)); ``` Should we fix this here along or in a dedicated pre-patch ?
  14. Christian Kuhn commented on patch set 5 07/15/22, 02:26

    Reply

    yeah. i actually also didn't manually test TS from sites ;) let me have a look on this, we'll then see if we incorporate in this patch, or have a pre-patch.
  15. Markus Klein commented on patch set 5 07/15/22, 09:01

    AnalyzerTreePanel.html:47 Reply

    I think you misread the link: Empty elements are defined as: "... cannot have any child nodes" td of course can have children.
  16. Christian Kuhn commented on patch set 5 07/15/22, 09:06

    Reply

    Yeah. Unsure about the collapsible 'options'. I went this way since it gives a systematic view of everything and 'boxing' them just looks better than having them standalone on top. They also take quite some space, this will be more obvious with the object browser, later. Imho: keep for now and see if anyone comes up with something better later. It's rather easy to change ... For the types: This is a very straight forward solution currently: The type is just created from the class name. There is a @todo to at least make them translatable. When changing this, we could add more explanation.

    Reply

    bug is rather obvious, actually. thx 4 pointing this out. i wonder why phpstan did not find this: it's an obvious case where an array is fed to sha1(). fixed and added a functional test now.

    TemplateAnalyzerController.php:50 Reply

    Done. Good this is gone. ExtendedTemplateService is one of the first targets to fall.

    TemplateAnalyzerController.php:58 Reply

    i'm currently updating uc when needed explicitly. don't understand full impact here, maybe we could have a quick chat on proper handling?

    TemplateAnalyzerController.php:81 Reply

    let's have a chat on how to properly handle these things.

    FineDiffViewHelper.php:2 Reply

    Ack

    IsInstanceOfViewHelper.php:36 Reply

    yeah. it's used in the recursive tree rendering to omit children if a condition did not match. using the condition interface and testing a tree node for this interface is a straight solution to achieve this. imho fine, at least for now.

    AnalyzerTreePanel.html:47 Reply

    i think you misinterpreted 'empty element' here. from your link: "An empty element is an element from HTML [...] that cannot have any child nodes". <td> of course *can* have children. it's fine to do that here.
  17. Christian Kuhn uploaded patch set 6 07/15/22, 09:06

  18. core-ci voted on patch set 6 V -1 07/15/22, 09:14 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29192

  19. Christian Kuhn uploaded patch set 7 07/15/22, 09:17

  20. core-ci voted on patch set 7 V +1 07/15/22, 09:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29196

  1. Christian Kuhn commented on patch set 7 07/15/22, 11:21

    TemplateAnalyzerController.php:58 Reply

    Done

    TemplateAnalyzerController.php:81 Reply

    Done
  2. Christian Kuhn uploaded patch set 8 07/15/22, 11:21

  3. core-ci voted on patch set 8 V +1 07/15/22, 11:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29203

  4. Andreas Kienast commented on patch set 8 07/15/22, 11:32

    AnalyzerTreePanel.html:22

    Missing locallang
  5. Andreas Kienast commented on patch set 8 CR -1 07/15/22, 11:34

    on it
  6. Andreas Kienast uploaded patch set 9 07/15/22, 11:37

  7. Andreas Kienast commented on patch set 9 07/15/22, 11:38

    Reply

    Done
  8. Andreas Kienast commented on patch set 9 07/15/22, 11:38

    AnalyzerTreePanel.html:22 Reply

    Done
  9. core-ci voted on patch set 9 V +1 07/15/22, 11:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29205

  10. Andreas Kienast commented on patch set 9 07/15/22, 11:47

    TemplateAnalyzerController.php:88

    I wonder whether we should make all the in_array() calls that are also added in other files strict.
  11. Christian Kuhn commented on patch set 9 07/15/22, 16:49

    TemplateAnalyzerController.php:88 Reply

    did that by intention here since getAllTemplateRecordsOnPage() is result of a DB operation which may return the uid as string.
  12. Simon Schaufelberger commented on patch set 9 07/15/22, 22:13

    AnalyzerTree.html:8

    please use additional html comments inside to make it clear that this is really a comment

    Analyzer.html:22

    same here

    Analyzer.html:41

    same here

    Analyzer.html:85

    same here
  13. Christian Kuhn commented on patch set 9 07/16/22, 10:52

    AnalyzerTree.html:8 Reply

    no. f:comment is enough. that't exactly what it is meant for, and it will not output. not reason to have more. that a comment meant to be read by source code readers.

    Analyzer.html:22 Reply

    no.

    Analyzer.html:41 Reply

    no.

    Analyzer.html:85 Reply

    no.
  14. Andreas Kienast commented on patch set 9 V -1 07/16/22, 13:32

    TreeBuilder.php:523

    implode() fails with "PHP Warning: Array to string conversion" if the settings array is nested.
  15. Andreas Kienast uploaded patch set 10 07/16/22, 13:33

  16. Andreas Kienast commented on patch set 10 07/16/22, 13:34

    TreeBuilder.php:523 Reply

    Done
  17. Andreas Kienast uploaded patch set 11 07/16/22, 13:36

  18. core-ci voted on patch set 10 V +1 07/16/22, 13:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29282

  19. core-ci voted on patch set 11 V -1 07/16/22, 13:44 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29283

  20. Andreas Kienast uploaded patch set 12 07/16/22, 13:49

  21. core-ci voted on patch set 12 V +1 07/16/22, 13:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29284

  22. Andreas Kienast voted on patch set 12 V +1 CR +1 07/16/22, 14:03

  23. Stefan Bürk voted on patch set 12 V +1 CR +1 07/16/22, 19:43

  24. Christian Kuhn voted on patch set 12 V +2 CR +2 07/16/22, 19:46

  25. Christian Kuhn merged patch set 13 07/16/22, 19:46