Review main Merged

61084[BUGFIX] Do not rely on TYPO3_MODE for FE/BE checks

Benni Mack CR +2 V +2 Easy +6 −4 updated 06/27/19, 12:23

Commit message

In order to run a subrequest in Frontend,
TYPO3_MODE kills most of the functionality.

Although it is clear, that TYPO3 Core is not 100% there
yet, some very obvious changes can actually be replaced
with simple TSFE checks instead of TYPO3_MODE.

This is only focused on rendering content (Fluid),
and this happens in FE after TSFE is initialized, for eID
scripts, this would break already.

Review

  • Code review CR +2 Done
    • Daniel Goerz +2
    • Alexander Schnitzler +1
    • Daniel Gorges +1
  • Verified V +2 Done
    • Daniel Goerz +2
    • Daniel Gorges +1
    • TYPO3com +1 CI

Issues 1

Files 2

Review log 1619

  1. Benni Mack uploaded patch set 1 06/18/19, 09:53

  2. Benni Mack updated the commit message in patch set 2 06/18/19, 09:54

  3. TYPO3com voted on patch set 1 V +1 06/18/19, 10:12 Completed build in 18m 38s on Tue, 18 Jun, 12:12 PM Test Summary: 46442 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34414

  4. TYPO3com voted on patch set 2 V +1 06/18/19, 10:17 Completed build in 15m 36s on Tue, 18 Jun, 12:17 PM Test Summary: 46442 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34416

  5. Helmut Hummel commented on patch set 2 06/18/19, 11:00

    AjaxWidgetContextHolder.php:54 Unresolved

    maybe isset($GLOBALS['TSFE']) && $GLOBALS['TSFE'] instanceof TypoScriptFrontendController

    AjaxWidgetContextHolder.php:95 Unresolved

    same here

    CObjectViewHelper.php:103 Unresolved

    same here

    CObjectViewHelper.php:138

    same here. maybe provide an API for that? Maybe Environment::isFrontendRequest or something similar
  6. Benni Mack uploaded patch set 3 06/18/19, 14:46

  7. Benni Mack commented on patch set 3 06/18/19, 14:48

    CObjectViewHelper.php:138 Reply

    yeah. I thought of adding this to the Context API back then (as Environment is rather focus on the instance and the PHP CGI/env), but was discussed with Olly to add it later, if needed. Environment API could actually be exposed in `typo3/cms-cli` to be "prepared" during build-time as well in the future to find the paths.
  8. TYPO3com voted on patch set 3 V +1 06/18/19, 15:01 Completed build in 15m 27s on Tue, 18 Jun, 05:01 PM Test Summary: 46442 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34424

  9. Benjamin Franzke commented on patch set 3 06/18/19, 15:15

    CObjectViewHelper.php:138 Reply Unresolved

    I agree that this isn't suitable for the Environment API. The information is derived from the request, that means it should be tied *to* the request. Speaking of PSR-7 that API would be a request attribute which would be set by a middleware (or alternatively a utility function that receives a PSR-7 ServerRequestInterface). Current usage will then be: isset($GLOBALS['TYPO3_REQUEST']) && $GLOBALS['TYPO3_REQUEST']->getAttribute('isFrontendRequest', false) Maybe you know what I want: Once we have proper PSR-7 Request context in fluid/viewhelpers we can receive this information without using $GLOBALS. But as we don't have that yet, $GLOBALS['TSFE'] is fine IMO as we can "swap" (temporarily override) that easily when we start with simulating frontend requests. (Same as we would do with $GLOBALS['TYPO3_REQUEST'])
  10. Daniel Goerz voted on patch set 3 CR +1 06/19/19, 06:13

  11. Alexander Schnitzler commented on patch set 3 06/19/19, 07:05

    AjaxWidgetContextHolder.php:54

    What about just ($GLOBALS['TSFE'] ?? null) instanceof TypoScriptFrontendController? I am pretty sure the null coalescing operator is right associative, hence the paranthesis.
  12. Benni Mack commented on patch set 3 06/19/19, 09:23

    AjaxWidgetContextHolder.php:54 Reply Unresolved

    all fine with me. the original patch worked for me, variant 2 as well, your suggestion too.
  13. Benni Mack commented on patch set 3 06/19/19, 14:27

    FYI. Most places in Core either use if (isset($GLOBALS['TSFE']) && $GLOBALS['TSFE'] instanceof TypoScriptFrontendController) { or if ($GLOBALS['TSFE'] instanceof TypoScriptFrontendController) { let's use one of these two (I don't mind which ones) for v9.5 - and we can streamline this then for master only separately.
  14. Alexander Schnitzler commented on patch set 3 06/19/19, 14:28

    > Patch Set 3: > > FYI. Most places in Core either use > > if (isset($GLOBALS['TSFE']) && $GLOBALS['TSFE'] instanceof TypoScriptFrontendController) { > > or > > if ($GLOBALS['TSFE'] instanceof TypoScriptFrontendController) { > > let's use one of these two (I don't mind which ones) for v9.5 - and we can streamline this then for master only separately. Sure, it's really just code beauty and not important at all. :)
  15. Benni Mack commented on patch set 3 06/19/19, 14:29

    haha :) TYPO3 and Code beauty...
  16. Alexander Schnitzler commented on patch set 3 CR +1 06/21/19, 06:34

    Can't verify at the moment as I don't have a project set up with a fluid widget.
  17. Daniel Gorges voted on patch set 3 V +1 CR +1 06/26/19, 04:14

  18. Daniel Goerz voted on patch set 3 V +2 CR +2 06/27/19, 12:23

  19. Daniel Goerz merged patch set 4 06/27/19, 12:23