Review main Abandoned

90714[BUGFIX] Lazily instantiate JavaScriptRenderer

Helmut Hummel CR -1 V 0 Easy +15 −11 updated 09/18/25, 09:17

Commit message

This is because the constructor calls $this->reset()
and in this method the JavaScriptRenderer is created
and for that a URI is generated, wich requires
a super global request to determine the correct URL prefix.

While this did not impose a problem until now,
it will in the future, when PageRenderer receives
a request object upon rendering, so that we can
get rid of global and super global request dependencies.

Instead of creating the instance of JavaScriptRenderer
in the reset method, use the getter in all places
upon rendering and instantiate JavaScriptRenderer lazily.

Review

  • Code review CR -1
    • Benjamin Franzke -1
  • Verified V 0
    • core-ci +1 CI

Issues 1

Files 1

Review log 69

  1. Helmut Hummel uploaded patch set 1 09/17/25, 20:44

  2. core-ci voted on patch set 1 V -1 09/17/25, 20:59 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85096

  3. Helmut Hummel uploaded patch set 2 V -1 09/17/25, 21:11

  4. core-ci voted on patch set 2 V -1 09/17/25, 21:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85098

  5. Helmut Hummel uploaded patch set 3 V -1 09/17/25, 21:48

  6. core-ci voted on patch set 3 V +1 09/17/25, 21:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85102

  7. Benjamin Franzke commented on patch set 3 CR -1 09/18/25, 06:53

    Unresolved

    I think this should be a TASK, as there is no known bug yet. A preparatory refactoring shall not be a BUGFIX.
    That'll be a great improvement. …but i don't think that means that JavaScriptRenderer needs to be lazy, I actually think that will not solve the problem. The JavaScriptRenderer is used as a registry by other components to park javascript module instructions via `PageRenderer->getJavaScriptRenderer()` (see DashboardController for an example), and therefore theoretically instantiated at any possible time (e.g. by middlewares). That means lazy instantiation can happen before PageRenderer `render()` is called. This will impose problems if the request object is not available by that time, since PageRenderer `render()` was not called yet. I'd instead suggest to change the JavaScriptRenderer when the *actual* PageRenderer change is done (so we can review and discuss less theoretical). The JavaScriptRenderer should be adapted to use a non-request dependant constructor (removing `$handlerUri`) and instead adding required arguments to `render()` and `renderImportMap()`. (We already started to do that with `$sitePath` and we could go on with more requirements once needed.)
  8. Helmut Hummel commented on patch set 3 09/18/25, 09:17

    Reply Unresolved

    Hm, sitePath is actually the only request dependency this thing has. For my change, that replaces the getStreamlinedFileName method with a new API that requires a request, but does not replace all PathUtility URL generating methods yet. I will therefore suggest to only remove passing the URI to the JavaScriptRenderer from the PageRenderer and refactor URI generation in JavaScriptRenderer and its child objects once replacing and deprecating the PathUtility calls in core.
  9. Helmut Hummel abandoned the change 09/18/25, 09:17