Review main Merged

56108[BUGFIX] Handle config.absRefPrefix on JS/CSS files correctly again

Oliver Hader CR +2 V +2 Hard +498 −2 updated 03/13/18, 09:08

Commit message

Issue #77589 introduced automatic resolving of relative paths during
v8.4.0 development in the PageRenderer component. Doing this in some
backend context is fine - however if applied for frontend rendering,
config.absRefPrefix was not applied anymore to these files.

Reason for this behavior is applying PathUtility::getAbsoluteWebPath
which prefixes files with /<TYPO3_SITE_PATH>/ - however absRefPrefix
only works on relative URIs. Extending the absRefPrefix patterns in
TypoScriptFrontendController::setAbsRefPrefix() by mentioned prefix
would adjust explicitly defined absolute paths as well.

To solve this bug, the prefix /<TYPO3_SITE_PATH>/ is
not applied in frontend rendering contexts anymore.

Review

  • Code review CR +2
    • Markus Klein +2
    • Stefan Neufeind +1
    • Susi Moog +1
  • Verified V +2
    • Markus Klein +2
    • Stefan Neufeind +1
    • Susi Moog +1
    • TYPO3com +1 CI

Issues 1

Files 3

Review log 4653

Show 2528 earlier messages
  1. Oliver Hader uploaded patch set 1 03/12/18, 12:29

  2. TYPO3com voted on patch set 1 V +1 03/12/18, 12:40 Completed build in 10m 45s on Mon, 12 Mar, 01:40 PM Test Summary: 30837 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-20835

  3. Markus Klein voted on patch set 1 CR +1 03/12/18, 12:54

  4. Susi Moog voted on patch set 1 CR +1 03/12/18, 12:56

  5. Susi Moog voted on patch set 1 V +1 03/12/18, 13:00

  6. Helmut Hummel commented on patch set 1 V -1 CR -1 03/12/18, 14:08

    PageRenderer.php:2529

    i'm pretty sure this is not correct, when you add a file with EXT: syntax. that file path we get here then is an absolute file path which of course is less useful for being exposed in html
  7. Helmut Hummel commented on patch set 1 03/12/18, 14:09

    I would also suggest to add (unit?) tests for that
  8. Oliver Hader commented on patch set 1 03/12/18, 14:10

    @Helmut: Did you test it or are you guessing?
  9. Oliver Hader commented on patch set 1 03/12/18, 14:13

    Unit testing is probably the wrong approach, since we want to test TSFE result and avoid simulating PageRenderer. Thus, it would be a full featured frontend request with having different TypoScript
  10. Helmut Hummel commented on patch set 1 03/12/18, 14:55

    > Unit testing is probably the wrong approach with current code in PageRenderer: might be Problem is that it currently acts on global state instead of getting this state injected. So yes, that is hard to unit test, especially when global state is a constant. for master, it would be pretty easy to change that and inject at least TYPO3_MODE into the object, which can then easily be passed in a unit test to verify different behaviour. but yes, a frontend test would also be good to have as well. should also be doable with our functional frontend testing framework (such things are done for fluid already)
  11. Helmut Hummel commented on patch set 1 03/12/18, 14:57

    PageRenderer.php:1401

    ok, problem is here…

    PageRenderer.php:1422

    … and here, where $this->getAbsoluteWebPath() is called with an absolute file path
  12. Susi Moog commented on patch set 1 03/12/18, 15:15

    PageRenderer.php:2529 Reply

    tested with inculdeCss and includeJs and EXT: path, with and without absRefPrefix - works...
  13. Helmut Hummel commented on patch set 1 03/12/18, 15:21

    PageRenderer.php:2529 Reply

    yes, this indeed works, as the absolute path is made relative in these places beforehand. what will stop working is requireJS with page renderer in frontend. not sure how may people are using this, but it is broken with this change (see a few lines above)
  14. Oliver Hader uploaded patch set 2 03/12/18, 15:31

  15. Oliver Hader commented on patch set 2 CR -1 03/12/18, 15:31

    Check carefully again, please
  16. Susi Moog commented on patch set 2 03/12/18, 15:34

    PageRenderer.php:2529 Reply

    Did you test that ever before the patch? Using the require js thing in frontend context is - let's just say - not a good idea. For one, there is only one cache identifier for the config independent of frontend or backend and then it registers all the core backend javascript by default if called. Looking at it, it does not seem to be meant as any kind of frontend API. I'd vote to add a comment to it to not be used in fe context (because it simply doesn't make sense) and be done with it. all other cases work afaics.
  17. Susi Moog commented on patch set 2 03/12/18, 15:35

    @olly - I'll test again, but I stand by my previous comment - that requireJs has no place at all in frontend requests.
  18. Susi Moog commented on patch set 2 03/12/18, 15:37

    > Patch Set 2: > > @olly - I'll test again, but I stand by my previous comment - that requireJs has no place at all in frontend requests. ... and we even have https://forge.typo3.org/issues/55264 << on that topic (last comment especially).
  19. TYPO3com voted on patch set 2 V +1 03/12/18, 15:39 Completed build in 08m 33s on Mon, 12 Mar, 04:39 PM Test Summary: 30837 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-20852

  20. Susi Moog commented on patch set 2 03/12/18, 16:12

    tested v2 with: - absRefPrefix: not set, auto, set absolute - file inclusion (css / js): with EXT: prefix and without - requireJS backend and frontend inclusion - css backend inclusion --> requireJS in frontend is broken exactly the same as before the patch, everything else I tested worked.
  21. Helmut Hummel commented on patch set 2 03/12/18, 19:19

    > Using the require js thing in frontend context is - let's just say - not a good idea I basically agree. Nevertheless I disagree with keeping code that adds absolute file paths to html output, because that is even more wrong.
  22. Helmut Hummel commented on patch set 2 03/12/18, 19:20

    and: if this is not called (or should not be called) in frontend, why do we add a code path here, that acts differently in frontend context?
  23. Susi Moog commented on patch set 2 03/12/18, 20:02

    > Patch Set 2: > > and: if this is not called (or should not be called) in frontend, why do we add a code path here, that acts differently in frontend context? I don't really care anymore, it's completely broken before and after (like not only conceptionally but in the I get a million JS errors kind of way) - for consistency I'd prefer the code paths to be similar, but honestly, do whatever you want, as it does not work in any case I don't think it's worth fuzzing over.
  24. Helmut Hummel uploaded patch set 3 03/12/18, 20:02

  25. TYPO3com voted on patch set 3 V +1 03/12/18, 20:11 Completed build in 09m 06s on Mon, 12 Mar, 09:11 PM Test Summary: 30837 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-20859

  26. Benjamin Kott voted on patch set 3 V +1 CR +1 03/12/18, 20:19

  27. Susi Moog voted on patch set 3 V +2 CR +2 03/12/18, 20:19

  28. Helmut Hummel commented on patch set 3 03/12/18, 20:20

    > like not only conceptionally but in the I get a million JS errors kind of way it might be broken conceptually, but with the changes reverted, it works even in FE. No JS errors here. > for consistency I'd prefer the code paths to be similar We could use the same code path, if we'd add absRefPrefix directly. Just making the file relative won't help if the result isn't added to src="" properties, as only they will be changed in absRefPrefix handling later.
  1. Susi Moog commented on patch set 3 03/12/18, 20:29

    > Patch Set 3: > > > like not only conceptionally but in the I get a million JS errors kind of way > > it might be broken conceptually, but with the changes reverted, it works even in FE. No JS errors here. I'm still getting them (even with this version of the patch as soon as I use $pagerenderer->loadRequireJs() - maybe that's a conflict with some js I am already loading).
  2. Oliver Hader voted on patch set 3 CR -1 03/12/18, 21:08

  3. Oliver Hader commented on patch set 3 03/12/18, 21:08

    Working on some tests...
  4. Susi Moog wrote 03/12/18, 21:33

    Removed Code-Review+2 by Susanne Moog <susanne.moog@typo3.org>
  5. Susi Moog wrote 03/12/18, 21:33

    Removed Verified+2 by Susanne Moog <susanne.moog@typo3.org>
  6. Oliver Hader uploaded patch set 4 03/12/18, 22:05

  7. Markus Klein updated the commit message in patch set 5 03/12/18, 22:10

  8. Markus Klein commented on patch set 5 CR -1 03/12/18, 22:11

    testing
  9. TYPO3com voted on patch set 4 V +1 03/12/18, 22:16 Completed build in 10m 56s on Mon, 12 Mar, 11:16 PM Test Summary: 30869 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-20867

  10. TYPO3com voted on patch set 5 V +1 03/12/18, 22:19 Completed build in 08m 55s on Mon, 12 Mar, 11:19 PM Test Summary: 30869 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-20868

  11. Susi Moog voted on patch set 5 V +1 CR +1 03/12/18, 22:21

  12. Markus Klein voted on patch set 5 V +2 CR +2 03/12/18, 22:26

  13. Oliver Hader voted on patch set 5 CR -1 03/12/18, 22:30

  14. Oliver Hader commented on patch set 5 03/12/18, 22:31

    Have a small test update for the negative check
  15. Oliver Hader uploaded patch set 6 03/12/18, 22:31

  16. Oliver Hader commented on patch set 6 CR -1 03/12/18, 22:32

    Argh..
  17. Oliver Hader uploaded patch set 7 03/12/18, 22:33

  18. Oliver Hader commented on patch set 7 03/12/18, 22:35

    Okay, done now... I've added checks to ensure that the original candidates are not in HTML anymore if being concatenated. Patchset 6 had a "strpos" vs "substr" flaw which is fixed now
  19. TYPO3com voted on patch set 6 V +1 03/12/18, 22:41 Completed build in 09m 38s on Mon, 12 Mar, 11:41 PM Test Summary: 30871 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-20870

  20. TYPO3com voted on patch set 7 V +1 03/12/18, 22:44 Completed build in 10m 29s on Mon, 12 Mar, 11:44 PM Test Summary: 30871 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-20871

  21. Susi Moog voted on patch set 7 V +1 CR +1 03/12/18, 22:44

  22. Markus Klein voted on patch set 7 V +2 CR +2 03/12/18, 22:44

  23. Stefan Neufeind voted on patch set 7 V +1 CR +1 03/13/18, 07:30

  24. Oliver Hader merged patch set 8 03/13/18, 09:08

  25. Oliver Hader commented on patch set 8 03/13/18, 09:08

    Cherry Picked This patchset was cherry picked to branch TYPO3_8-7 as commit f30d7c2871734142984fbf3bfe5c9e2a260bd377