Review main Merged

47678[FEATURE] Add fluid debug information to admin panel

Frank Nägler CR +2 V +2 Normal +191 −0 updated 10/06/16, 16:38

Commit message

This patch adds a new option to the admin panel to show debug information
about partials and sections in frontend.

Review

  • Code review CR +2
    • Anja Leichsenring +2
    • Jan Helke +1
  • Verified V +2
    • Anja Leichsenring +2
    • Jan Helke +1
    • TYPO3com +1 CI

Issues 1

Files 6

Review log 5667

Show 3942 earlier messages
  1. Frank Nägler uploaded patch set 1 04/14/16, 20:14

  2. Frank Nägler updated the commit message in patch set 2 04/14/16, 20:15

  3. Frank Nägler uploaded patch set 3 05/09/16, 08:41

  4. Gianluigi Martino commented on patch set 3 V +1 05/09/16, 09:03

    Nice
  5. Marcin Krzyżanowski commented on patch set 3 V +1 05/09/16, 12:33

    Works great! However, from frontend/usability point of view using "overflow:overlay" instead of "overflow:hidden" is better option for smaller partial boxes. Now you are not able to see full partial path when this red box is small and what is more, you cannot scroll.
  6. Frank Nägler commented on patch set 3 05/09/16, 12:39

    yes, but the full path is also in the title attribute.
  7. Nicole Hummel commented on patch set 3 05/09/16, 13:35

    RenderViewHelper.php:87

    !empty() as the keys might not be set

    RenderViewHelper.php:121

    user input - should be escaped

    AdminPanelView.php:387

    !empty()
  8. Frank Nägler commented on patch set 3 CR -1 05/09/16, 13:44

    on it

    RenderViewHelper.php:87 Reply

    good point, will update

    RenderViewHelper.php:121 Reply

    no user input, it is a calculated path, which contains markup, see the render method above.

    AdminPanelView.php:387 Reply

    will update
  9. Frank Nägler uploaded patch set 4 05/09/16, 13:47

  10. Nicole Hummel commented on patch set 4 CR -2 05/09/16, 14:18

    I talked to Helmut and we came to the conclusion that this is a quick and dirty feature implementation. We suggest to extend the Fluid Standalone to be able to implement own Interceptors which can handle some system-defined output (like wrapping additional information). We will see what we can do for this Standalone feature at the current sprint in Cluj
  11. Frank Nägler commented on patch set 4 05/09/16, 14:20

    if you think this is a "quick and dirty" solution feel free to find a better solution.
  12. Nicole Hummel uploaded patch set 5 05/09/16, 18:37

  13. Nicole Hummel commented on patch set 5 05/09/16, 18:39

    This patch needs an upcoming fix in Fluid Standalone
  14. Nicole Hummel commented on patch set 5 05/10/16, 08:26

    I split this patch to introduce new interceptor registration in an own patch. Please lets get this on into the core and merge this patch afterwards. You can find the new patch here https://review.typo3.org/48055/
  15. Claus Due commented on patch set 5 05/17/16, 15:31

    It would result in much better performance if these parameters were extracted from a debug-adapted TemplatePaths or RenderingContext object - changing the escaping interceptor behaviors is extremely costly in comparison. Placing it there also lets you extract information about namespaces and more.
  16. Claus Due commented on patch set 5 05/17/16, 15:39

    On the subject of own interceptors: this is already possible and should be done via the RenderingContext->buildParserConfiguration method. This sets interceptors globally. https://github.com/TYPO3Fluid/Fluid/blob/master/src/Core/Rendering/RenderingContext.php#L314 I would not encourage modifying the interceptors in any other way than this, and if using this way, I would be extremely careful about which interceptors to enable and possibly customise them based on context. A general registry of interceptors that are always loaded seems excessive; targets too broadly. If it really is required to add interceptors dynamically I would recommend that this gets done for example per extension - in other words consider it a setting of the same level and importance as template paths, for example configured in the same TS scope.
  17. Nicole Hummel commented on patch set 5 05/17/16, 20:19

    Hi Claus, Thanks for your feedback. To be honest I don't understand it completely. Maybe you can help out and give me some more information about your vision. > It would result in much better performance if these parameters were > extracted from a debug-adapted TemplatePaths or RenderingContext > object - changing the escaping interceptor behaviors is extremely > costly in comparison. I don't see any code which changes the escaping interceptor behavior? My vision was to introduce a way how own interceptors can be added to the configuration (not only for debugging purpose). If I understand the Fluid Standalone code correctly, the configuration object already has methods to register new interceptors but the Fluid Standalone RenderingContext hasn't any API to define own ones. Therefore I pushes the patch https://review.typo3.org/48055/ to implement the configuration in TYPO3 core itself. I see this debug interceptor than as a consumer using the provided core API. > Placing it there also lets you extract information about namespaces > and more. I don't understand your "there". Where would you place API to add (in this case) the debug information about paths and sections? As this patch addresses an option in the admin panel, I don't see any good way how to influence some TemplatePaths or RenderingContext objects without having new core dependencies (checking the status of the admin penal, provided by some globals vars). > On the subject of own interceptors: this is already possible and > should be done via the RenderingContext->buildParserConfiguration > method. This sets interceptors globally. > > https://github.com/TYPO3Fluid/Fluid/blob/master/src/Core/Rendering/RenderingContext.php#L314 As I said, IMHO this patch already uses that API correctly by its own core RenderingContext->buildParserConfiguration. I haven't found any Fluid Standalone way how to influence the used configuration objects and adding own interceptors. > I would not encourage modifying the interceptors in any other way > than this, and if using this way, I would be extremely careful > about which interceptors to enable and possibly customise them > based on context. A general registry of interceptors that are > always loaded seems excessive; targets too broadly. If it really is > required to add interceptors dynamically I would recommend that > this gets done for example per extension - in other words consider > it a setting of the same level and importance as template paths, > for example configured in the same TS scope. I do understand that you would like some TS configuration but don't understand how you would solve the tickets issue, to add a new admin panel configuration which would add the debug output to each extension/plugin. Maybe you have any idea how to solve both approaches?
  18. Claus Due commented on patch set 5 05/17/16, 22:22

    This may be a bit long so for everyone, the TL;DR is: avoid interception, create a debug-friendly renderingcontext instead because interception is both too expensive and in this form causes ill effects in compiled templates. @Nicole I'll try to explain my idea Speaking of an API to insert interceptors in general: Absolutely true that changing escaping interceptors is and will remain a feature of standalone Fluid - and it is indeed done exactly the way you propose in the other patch. So in and of itself, the other patch is probably fine. Although I would not put it in the buildParserConfiguration method, or at least cache it, but that's more of a review of the other patch and not something for this discussion. As far as I am concerned that patch is okay, though like with everything else there's room for improvement. Regarding *this* patch: The intention is to output (inline, hidden) HTML when `f:render` is called. But the chosen tool is to selectively add interceptors which also get compiled. These interceptors must be executed every time a ViewHelper is invoked (to check if that ViewHelper is the one we target). That is the solution I would not encourage. It is too expensive - and causes differences in compiled templates when user logs out again. Working around *that* compiling issue causes even more checks and conditions which imho just makes it worse. For this specific use case then it would appear that it's better to - and this is again just an example - use a custom TemplatePaths object that can store the templates you resolved and output this storage as inline HTML somewhere *outside* if the whole compiling/parsing logic of Fluid. Because what you want to debug here is "which templates did I render?" and this information can just as well be collected after rendering finishes. Storing resolved resources is extremely cheap - intercepting everything to target a tiny speck is super expensive in comparison. Another reason I have for suggesting this is the expectation that other things would also be nice to debug. For example, which namespaces a template contains and which ViewHelpers were called with which arguments. Interceptors will never be able to solve anything other than when a ViewHelper or ObjectAccessorNode is used - inspecting the context helpers after rendering can yield so much more information. So yes, I have an idea to solve both approaches: Manipulate the RenderingContext and the classes it delivers - personally I would do it with a subclassed DebugRenderingContext. If the helpers don't already track the info you need (TemplatePaths already keeps track, maybe that's sufficient for now) then subclass those (already done for most of them in TYPO3) and override methods as needed to add tracking/logging. Append this tracked information as HTML where appropriate, for example in https://github.com/TYPO3Fluid/Fluid/blob/master/src/View/AbstractTemplateView.php render, renderSection, renderPartial methods once the template's HTML is returned (I would personally not do this; I'd output them near end of page, but I understand that adminpanel needs this). Result would be the same as using an interceptor but magnitudes cheaper with no problem debugging compiled templates - once user logs out the standard RenderingContext is used again so you don't risk outputting debug HTML (CSS-visible or not) when it shouldn't be output. It would also work for the backend (to display for example in the debug console). Added bonus :) And regarding triggering this with TS: I would enable this debugging only when the TS enables it. For example, you could set `plugin.tx_myext.view.debug = 1` in TS and select the RenderingContext class name based on that. It would also be okay to have a global flag but I would certainly also support selectively targeting each extension (and TS seems the ideal tool for that). Hope fully that explains it.
  19. Nicole Hummel commented on patch set 5 05/18/16, 06:58

    > Although I would not put > it in the buildParserConfiguration method, or at least cache it, > but that's more of a review of the other patch and not something > for this discussion. As far as I am concerned that patch is okay, > though like with everything else there's room for improvement. Can you add a comment on this to the other patch please (or push a new patch set according to your thoughts)? > The intention is to output (inline, hidden) HTML when `f:render` is > called. > > But the chosen tool is to selectively add interceptors which also > get compiled. These interceptors must be executed every time a > ViewHelper is invoked (to check if that ViewHelper is the one we > target). > > That is the solution I would not encourage. It is too expensive - > and causes differences in compiled templates when user logs out > again. Working around *that* compiling issue causes even more > checks and conditions which imho just makes it worse. I don't get your point, sorry. The interceptor is called only if the option in the admin panel was enabled. IMHO if I want to debug any code, I don't care that much about performance. I want the necessary information to help me for further development. And we don't know what other interceptors might want to do, so we can't discuss any other situation. > For this specific use case then it would appear that it's better to > - and this is again just an example - use a custom TemplatePaths > object that can store the templates you resolved and output this > storage as inline HTML somewhere *outside* if the whole > compiling/parsing logic of Fluid. Because what you want to debug > here is "which templates did I render?" and this information can > just as well be collected after rendering finishes. This isn't true as it's not that helpful seeing the compiled templates and partials at the end of the site as seeing that information in the content context. The goal of the patch is to help editors find the template/partial for a specific content element to be able to adjust that to their needs. Not showing the used templates/partials in general. > > Another reason I have for suggesting this is the expectation that > other things would also be nice to debug. For example, which > namespaces a template contains and which ViewHelpers were called > with which arguments. Showing namepsace information isn't scope of this patch neither. To be honest I don't see any reason why you should need that anyway. Displaying information about used viewhelper with their arguments can be handeled by interceptors as well. You get all child nodes and their arguments. So if you want, you could add that to the output as well. > So yes, I have an idea to solve both approaches: > > Manipulate the RenderingContext and the classes it delivers - > personally I would do it with a subclassed DebugRenderingContext. That would add unnecessary dependencies (check if any debug mode is enabled) to the intitialization if the Fluid. As I said, I want to prevent any "debug" context which than does magic stuff in the background.
  20. Nicole Hummel commented on patch set 5 CR 0 09/16/16, 11:06

    I would kindly ask you to read Claus comments on the implementation details, when working on a new patch set. I tend to add this feature in development context only.
  21. Frank Nägler uploaded patch set 6 09/19/16, 18:24

  22. Frank Nägler commented on patch set 6 CR -1 09/19/16, 18:26

    on it
  23. TYPO3com voted on patch set 6 V -1 09/19/16, 18:27 Completed build in 03m 13s on Mon, 19 Sep, 08:27 PM Test Summary: 18529 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3130

  24. Nicole Hummel commented on patch set 6 09/19/16, 18:29

    DefaultConfiguration.php:278

    wrong change

    ext_localconf.php:6

    As said in my comment I would really like to couple this setting to the development context to not affect production systems.
  25. Frank Nägler uploaded patch set 7 09/19/16, 19:37

  26. TYPO3com voted on patch set 7 V +1 09/19/16, 19:40 Completed build in 03m 23s on Mon, 19 Sep, 09:40 PM Test Summary: 18529 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3131

  27. Claus Due commented on patch set 7 CR -1 09/19/16, 21:47

    I have an alternative suggestion: * Create a subclass or alternative of `f:render` in another namespace * In ViewHelperResolver, override the returned namespaces to overlay this new namespace The change would only need one new class and one simple change to ViewHelperResolver. And rather than checking each and every node (of any type) that is created, if that node is the one single ViewHelper we target, we instead explicitly overrule that one ViewHelper using the built-in feature of multiple namespace lookups. Furthermore this opens the door to integrating debug info for any ViewHelper (CMS or standalone Fluid!) by merely creating a new class in this overruling namespace - no further need to configure an interceptor or change the interceptor to target more than `f:render`. And perhaps most importantly, it prevents the size and scope of interception from growing out of control - because it really is a part of the API you should absolutely only tough in those cases where you need to explicitly target any and all node types. Targeting a single ViewHelper this way is definitely not the intended function of interceptors! If you need help with this let me know. I may not have time to take over the creation of the feature but I can assist with information about how to use the ViewHelperResolver to add namespaces that overrule/overlay the native ones.
  28. Frank Nägler commented on patch set 7 09/19/16, 21:50

    Hi Claus, thx for your feedback. If I understand you correctly, your suggestion is a solution like my first approach (see patchset 1 to 4)
  29. Claus Due commented on patch set 1 09/19/16, 22:02

    @Frank yes, pretty much - except you should duplicate/subclass it to another namespace and leave the original untouched, then ensure that the duplicate/subclass class name is only returned when you are in Development context. I can't say for sure at this point (getting tired and don't remember) but it may even make sense to put these in for example TYPO3\CMS\Fluid\ViewHelpers\Development\RenderViewHelper (which allows it to be used explicitly also in production using `f:development.render`. There may be some (very valid) objections to this though ;)
  30. Georg Ringer commented on patch set 7 09/20/16, 08:41

    DebugInterceptor.php:118

    we still allow typo3/ext/

    DebugInterceptor.php:137

    there is an adminpanel css which could be used, so no inline css required

    AdminPanelView.php:398

    please remove this check, no setting is bount to the application context and the admin panel is the only thing we have to debug a production system
  31. Helmut Hummel commented on patch set 7 09/21/16, 15:03

    @Claus, thanks for your suggestion to use the ViewHelperResolver to switch the RenderViewHelper in case debugging is requested. That simple solution did not come to my mind. @Frank, sorry if "your solution is hacky" sounded harsh to you. I talked with Nicole, came to the same conclusion namely that it is a bit hacky, or to put it into different words, too coupled when putting debug functionality in one of the most important view helpers of fluid. It would violate the single responsibility principle to do so. The only way to decouple the code which came to my mind back then, was using an interceptor. The interceptor transparently changes the functionality for the view helper if requested. By that, we could have decoupled debug functionality from the render view helper and let it just do its main responsibility (rendering stuff). Meanwhile Claus came up with an approach that fulfills the requirement of decoupling, but is easier to understand and has less overhead that intercepting each node during rendering. I'm absolutely fine with that approach. I feel a bit sad about throwing away the interceptor we already have now, but that is how software works, you throw away stuff if somebody comes up with a nicer or easier solution ^^ Creating a dedicated render view helper for debugging and keeping the original one for "regular" rendering and putting the switch logic NOT into a subclassed render view helper fulfills the requirement of separating concerns. The ViewHelperResolver has the responsibility to find the correct view helpers and we just extend this task a bit by adding some more context info. The main render view helper can stay untouched. The debug render view helper also still renders stuff, but in this case with some additional HTML. So from an architectual point of view, it should be clear what to do now. And no, it is not exactly like Frank's first approach. The first approach mixed several concerns in one sublcass. Now we changed a "hacky" implementation of a great feature into a nice decoupled more maintainable implementation. Although it took some time, I think it was worth the wait and the discussion. What till needs to be evaluated, is how this affects cached rendering of templates. Is the resolved debug view helper compiled into the cache, that a switch to production would still produce debug output? And what also needs to be figured out is the concept for the user interaction when using this feature. This was brought onto the table by Georg and it is something important to agree upon. I personally have no strong opinion on that, I only want to stress that the feature should be easily discoverable. Hope this explains a bit the history of this change, the reasons for intervention. I personally don't have the impression that something was blocked here, but input from different sides with different perspectives slowly turn a nice feature idea into a great, usable and maintainable feature for TYPO3. At least to me it is a nice example that collaboration and qualified feedback leads to better results than hurrying things in and fixing it later (or never).
  32. Philipp Gampe commented on patch set 7 09/21/16, 16:00

    IMHO the admin panel checkbox should not be bound to the debug context. What could be done is, that the debug context triggers html comments with the paths, whereas the admin panel checkbox triggers the frontend output of the same information. That means the first is more for developers, while the later is for integrators.
  33. Helmut Hummel commented on patch set 7 09/21/16, 16:19

    > IMHO the admin panel checkbox should not be bound to the debug context We need a way to cleanly and reliably switch the view helper from regular render view helper to debug render view helper. The question is, how to cleanly solve this without much coupling between the admin panel code and the view helper resolver code.
  34. Claus Due commented on patch set 7 09/21/16, 18:15

    The friendliest and smallest way in terms of API would be to add an overlay namespace (see previous comment, I suggested TYPO3\CMS\Fluid\ViewHelpers\Debug which would mean you can also do f:debug.render to force debugging on!). This can be done in ViewHelperResolver by overriding initialization to add a third namespace if context is development. I strongly encourage going this way with the feature since it is clean, works in compiled templates, executes only once per view context and gives us a completely separate class name we can target with unit tests as well. We can also make said ViewHelpers throw warnings if used in Production context. Finally, putting it in the sub-scope of normal ViewHelpers would be my personal choice to gain more flexibility.
  35. Jigal van Hemert commented on patch set 7 09/21/16, 18:47

    I'd vote for using the viewHelperResolver, but I don't like to have the feature only in development context. As it's a feature for the admin panel it should be active if the admin panel is active no matter if you're in production or development context.
  36. Claus Due commented on patch set 7 09/21/16, 19:06

    It would be possible in ViewHelperResolver to overlay the namespaces based on any condition, no problem there. I have no objection to that either, as long as the overlay only happens when explicitly requested.
  37. Claus Due commented on patch set 7 09/21/16, 19:20

    Just to follow up on what Helmut already said, sorry about the delay - I really wish I had come up with the namespace overlay idea much earlier! The result however is probably going to open a lot of new possibilities for inspecting stuff that goes on in Fluid, like namespaces of a template, classes involved, usage statistics, "compilable?" insight, basic profiling and whatnot. So I'm quite happy with that and thank you Frank for opening this new door ;)
  38. Helmut Hummel commented on patch set 7 09/21/16, 19:20

    @Claus I thought I made myself clear in the statement, but it maybe was to long :) tl;dr: I agree with using your suggestion with ViewHelperResolver :)
  39. Claus Due commented on patch set 7 09/21/16, 19:21

    You did, Helmut - I just missed the comment initially and didn't read it until a few minutes ago ;)
  40. Claus Due uploaded patch set 8 09/21/16, 19:43

  41. TYPO3com voted on patch set 8 V -1 09/21/16, 19:46 Completed build in 03m 12s on Wed, 21 Sep, 09:46 PM Test Summary: 18531 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3171

  42. Claus Due uploaded patch set 9 09/21/16, 19:47

  1. Claus Due uploaded patch set 10 09/21/16, 19:49

  2. TYPO3com voted on patch set 9 V -1 09/21/16, 19:50 Completed build in 03m 11s on Wed, 21 Sep, 09:50 PM Test Summary: 18531 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3172

  3. TYPO3com voted on patch set 10 V -1 09/21/16, 19:53 Completed build in 03m 51s on Wed, 21 Sep, 09:53 PM Test Summary: 18531 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3173

  4. Claus Due uploaded patch set 11 09/21/16, 19:53

  5. Claus Due uploaded patch set 12 09/21/16, 19:55

  6. Claus Due commented on patch set 12 09/21/16, 19:57

    Sorry about the push spam guys... patch 12 should fill the requirements but is untested. If nothing else it should clearly show the intended implementation!
  7. TYPO3com voted on patch set 11 V -1 09/21/16, 19:57 Completed build in 03m 47s on Wed, 21 Sep, 09:57 PM Test Summary: 18531 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3174

  8. Claus Due uploaded patch set 13 09/21/16, 19:58

  9. TYPO3com voted on patch set 12 V -1 09/21/16, 19:59 Completed build in 03m 36s on Wed, 21 Sep, 09:59 PM Test Summary: 18531 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3175

  10. Claus Due commented on patch set 13 09/21/16, 20:01

    While I have this open: should I add an "arguments" dump (DebuggerUtility::var_dump with inline=true) to this same debug info? That might be valuable information but would cause quite a bit of output.
  11. TYPO3com voted on patch set 13 V -1 09/21/16, 20:01 Completed build in 03m 31s on Wed, 21 Sep, 10:01 PM Test Summary: 18531 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3176

  12. Georg Ringer uploaded patch set 14 09/22/16, 11:56

  13. TYPO3com voted on patch set 14 V -1 09/22/16, 12:00 Completed build in 03m 14s on Thu, 22 Sep, 02:00 PM Test Summary: 18531 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3183

  14. Frank Nägler uploaded patch set 15 10/02/16, 15:11

  15. Frank Nägler voted on patch set 15 CR +1 V +1 10/02/16, 15:11

  16. TYPO3com voted on patch set 15 V -1 10/02/16, 15:15 Completed build in 03m 24s on Sun, 2 Oct, 05:15 PM Test Summary: 18535 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3311

  17. Frank Nägler uploaded patch set 16 10/02/16, 15:15

  18. TYPO3com voted on patch set 16 V +1 10/02/16, 15:19 Completed build in 03m 05s on Sun, 2 Oct, 05:19 PM Test Summary: 18535 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3312

  19. Jan Helke voted on patch set 16 V +1 10/06/16, 15:40

  20. Anja Leichsenring commented on patch set 16 CR +1 V +1 10/06/16, 15:40

    works as advertised. The paths are cut, if no space is left in the view, but I don't consider this a blocker, after the code inspection of the browser can reveal the full path. If someone feels like improving this display issue, a followup will be good enough.
  21. Jan Helke voted on patch set 16 CR +1 10/06/16, 15:41

  22. Anja Leichsenring voted on patch set 16 CR +2 V +2 10/06/16, 15:41

  23. Gerrit merged patch set 16 10/06/16, 15:41

  24. Anja Leichsenring commented on patch set 17 10/06/16, 16:34

    Reverted This patchset was reverted in change: I3e964a95444f8d6fd0f71644c094616ac7c63755
  25. Anja Leichsenring commented on patch set 17 10/06/16, 16:38

    reverted with https://review.typo3.org/50094 due to unwanted changes in BE. and repushed at https://review.typo3.org/#/c/50095/