4

After upgrading to TYPO3 v9.5.14 our detail pages for news crash with the exception

Symfony\Component\Routing\Exception\InvalidParameterException

Parameter "p88bd715a41119d0e8087a5d19cb049" for route "tx_news_pi1_1" must match "[^/]++" ("" given) to generate a corresponding URL.

What's going on?

The site used this configuration:

  NewsTagPlugin:
    type: Extbase
    limitToPages: [14]
    extension: News
    plugin: Pi1
    routes:
      - routePath: '/{tag-name}'
        _controller: 'News::list'
        _arguments:
          tag-name: 'overwriteDemand/tags'
      - routePath: '/{tag-name}/page/{page}'
        _controller: 'News::list'
        _arguments:
          tag-name: 'overwriteDemand/tags'
          page: '@widget_0/currentPage'
          requirements:
            page: '\d+'
    defaultController: 'News::list'
    defaults:
      page: ''
    aspects:
      page:
        type: IntegerMapper
        start: 1
        end: 5000
      tag-name:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_tag
        routeFieldName: slug
Peter Kraume
  • 3,577
  • 2
  • 21
  • 39
M Klein
  • 553
  • 2
  • 10

2 Answers2

5

1) Superfluous mapping

  NewsTagPlugin:
    ...
    routes:
      ...
      - routePath: '/{tag-name}/page/{page}'
        _controller: 'News::list'
        _arguments:
          tag-name: 'overwriteDemand/tags'
          page: '@widget_0/currentPage'
          requirements:
            page: '\d+'
  • _arguments defines a mapping for route parameter and internal variables (e.g. as query parameter`
  • requirements is wrong here, since it shall not be used as argument mapping
  • parameter requirements need to be defined on the root level of NewsTagPlugin

2) Invalid empty default value

  NewsTagPlugin:
    ...
    routes:
      ...
      - routePath: '/{tag-name}/page/{page}'
      ...
    defaults:
      page: ''
    aspects:
      ...
  • defaults was not applied prior to TYPO3 v9.5.14 and addressed in https://review.typo3.org/c/Packages/TYPO3.CMS/+/60361
  • the empty default value for parameter page does not make much sense and would lead to an URL like /some-tag/page/ which is causing the error message shown in the answer
  • the default value should be page: 1
  • in case the parameter should be omitted in the URL (e.g. having /some-tag/page/) this needs to be defined explicitly using {!page} in the route path

References

Adjusted enhancer configuration

  NewsTagPlugin:
    type: Extbase
    limitToPages: [14]
    extension: News
    plugin: Pi1
    routes:
      - routePath: '/{tag-name}'
        _controller: 'News::list'
        _arguments:
          tag-name: 'overwriteDemand/tags'
      - routePath: '/{tag-name}/page/{!page}'
        _controller: 'News::list'
        _arguments:
          tag-name: 'overwriteDemand/tags'
          page: '@widget_0/currentPage'
    defaultController: 'News::list'
    defaults:
      page: 1
    aspects:
      page:
        type: IntegerMapper
        start: 1
        end: 5000
      tag-name:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_tag
        routeFieldName: slug
  • (untested) since IntegerMapper seems to be a custom aspect implementation - not being available to the public
Oliver Hader
  • 4,093
  • 1
  • 25
  • 47
  • I disagree on some points. The setup described in the question worked without errors in 9.5.13. The URLs for the pages were /tag-name/ /tag-name/page/2 /tag-name/page/3 This was working and required the setup to have the default value as empty string. Your example assumes page:1 as default, which is wrong for the desired URLs. – M Klein Feb 18 '20 at 15:24
  • `IntegerMapper` is indeed a custom mapper, that does nothing special except being faster than what the core shipped so far. – M Klein Feb 18 '20 at 15:38
0

First off, consider https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/9.5.x/Important-86895-RouteAspectsTakePrecedenceOverRequirements.html

The culprit is the default configuration for the page aspect. It was once introduced to make sure that the URL for the first tag page is always "/tag-name" and only subsequent pages have "/tag-name/page/2" and so on.

This default value now needs to be removed in order to have the requirements applied as desired.

Oliver Hader
  • 4,093
  • 1
  • 25
  • 47
M Klein
  • 553
  • 2
  • 10