Issue Bug Closed

#102773Static route causes type error when using EXT: syntax

Lina Wolf 01/08/24, 08:38 updated 07/09/24, 15:12

Description

When I define a static route like this in TYPO3 v12.4.9, PHP 8.2:

routes:
  -
    route: robots.txt
    type: staticText
    source: 'EXT:my_sitepackage_mysite/Resources/Public/robots.txt'

I get a type error:

TYPO3\CMS\Core\Http\HtmlResponse::__construct(): Argument #1 ($content) must be of type string, null given, called in /var/www/html/vendor/typo3/cms-frontend/Classes/Middleware/StaticRouteResolver.php on line 60

I would expect the EXT syntax to work here. But even if the file is not found it should not cause a PHP type Error

Reviews 2

Files 1

History 37

  1. Lina Wolf commented and changed attached clipboard-202401080957-heqww.png assigned to Lina Wolf 01/08/24, 09:07

    After some investigation what happened here is the following:

    - I first saved the static route as type “staticText” in the site module.

    Then switched to using type “uri” with “EXT:mysitepackage/..” in the site module.

    After saving no red error or some such is displayed but when I open the static file page again I get:

    clipboard-202401080957-heqww.png

    And some inconsistent data is saved into the config.yaml:

    routes:
      -
        route: robots.txt
        type: staticText
        source: 'EXT:my_sitepackage_mysite/Resources/Public/robots.txt'

    Note how the type staticText is used but a source, not a content displayed?

    Now in the StaticRouteResolver, line 142 we just expect the “content” is set in the $routeConfig array for that type, which it is not after the GUI messed up the file.

    I could not reproduce how the YAML got messed up in current main

  2. Gerrit Code Review pushed patch set 1 for main to change 82367 status New Under Review 01/08/24, 09:09

  3. Gerrit Code Review pushed patch set 2 for main to change 82367 01/08/24, 09:10

  4. Gerrit Code Review pushed patch set 3 for main to change 82367 01/14/24, 09:00

  5. Gerrit Code Review pushed patch set 1 for 12.4 to change 82478 01/18/24, 08:06

  6. Lina Wolf commented and changed status Under Review Resolved done 0 % 100 % 01/18/24, 08:15

    Applied in changeset commit:3dc75cf86d23484123b477478cad99d10d590e66.

  7. Benni Mack changed status Resolved Closed 07/09/24, 15:12