Issue Bug Closed

#100361"vendor/bin" in absolute URL from f:uri.resource in command controller

Rudy Gnodde 03/30/23, 13:52 updated 03/25/25, 14:07

Description

We have a command controller that fills/renders a `StandaloneView`. The template contains `<f:uri path="EXT:myext/..." absolute="1"></f:uri>`. When executing the Command Controller from cli with `env HTTP_HOST=domain` the link includes `vendor/bin`.

To test this I’ve created a minimal extension https://github.com/FamousWolf/clilinktest. After installing this extension you can execute `env HTTP_HOST=domain vendor/bin/typo3 clilinktest:link-test`. This will output `Resource link: http://domainvendor/bin/_assets/8941a1cc0cfaf55c24b1ffcd159f5d1c/Images/Test.svg`. Expected output is `http://domain/_assets/8941a1cc0cfaf55c24b1ffcd159f5d1c/Images/Test.svg`.

I’ve tested this in a clean composer installed TYPO3 11.5 and 12.3 instance.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 3

  1. Stephan Großberndt changed Related to #90330 09/13/23, 07:47

  2. Benni Mack commented and changed status New Closed 03/25/25, 12:35

    As there is no context under which domain (or SSL or non-SSL) the system is running, it is impossible for CLI scripts to guess this.

    The best way is to simulate a Http Request. I’ve done this in project where I knew which domain I wanted to use and set $_SERVER[…] in my CLI command.

    See https://github.com/b13/warmup as for some ugly examples on how to boot up a frontend as well.

    IMHO this is a limitation of PHP, and TYPO3 can not guess. In TYPO3 versions until v9, TYPO3 “guessed” the domain by checking sys_domain records, which was just wrong on so many levels… (it just took the first one). Unfortunately, there is nothing we can do to guarantee this.

    I assume we could have a “simulate web request” solution at some point, but I’d rather try this in a third-party extension than in core. If you up for it, create an extension and let me know.

    I hope it’s OK, if I close this ticket in the meanwhile…

  3. Rudy Gnodde commented 03/25/25, 14:07

    The context of domain can be set using `env HTTP_HOST=domain` (and SSL by adding `HTTPS=on`). The problem is `vendor/bin` is added to the URL.

    It can be “fixed” by executing `cd vendor/bin ; env HTTP_HOST=domain HTTPS=on php typo3 clilinktest:link-test` instead of `env HTTP_HOST=domain vendor/bin/typo3 clilinktest:link-test`. Not the cleanest solution, but it will do for now.