Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RouteEnhancer with aspect type "NewsTitle" breaks 404 handling in TYPO3 12 #2362

Open
kanow opened this issue Mar 5, 2024 · 2 comments
Open

Comments

@kanow
Copy link
Contributor

kanow commented Mar 5, 2024

Bug Report

Current Behavior
Using aspect type "NewsTitle" in RouteEnhnacer for news url routing breaks the 404 handling. If set and a wrong url is requested, the homepage of the website is shown (with news plugin on it) and error message "artcile not available" is visible. Plugin on the homepage is list+detail view. If I change this to news_newsliststicky, the list with news items is shown.

Expected behavior/output
If a wrong url is requested my 404 error page should be shown in frontend. Not the homepage of the website.

Environment

  • TYPO3 version(s): 12.4.1
  • news version: 11.4.1
  • Is your TYPO3 installation set up with Composer (Composer Mode): yes
  • OS:Local development with docker. Apache2 webserver

Possible Solution
If I change the aspect type to the old PersistedAliasMapper with the needed configuration for table and field, everything is fine. 404 pageworks like expected.

Additional context
I don't understand why the PersistedAliasMapper/NewsTitle Aspect is called on a page without any plugin. No news, no other plugins. Just a wrong url!
I'm using limitToPages in my config.yaml
Just an idea, maybe something goes wrong in the TYPO3 core AspectFactory and the NewsTitle Aspect is cheating in between?

@benjamingries
Copy link

I can confirm this issue. Error handling will be broken for all pages if you don't use limitToPages option. Otherwise it will be only broken on these pages that are listed under this option.

Example configuration:

routeEnhancers:
  News:
    type: Extbase
    // limitToPages:
    //  - 5
    //  - 6
    extension: News
    plugin: Pi1
    routes:
      - routePath: '/'
        _controller: 'News::list'
      - routePath: '/{page-label}-{page}'
        _controller: 'News::list'
        _arguments:
          page: 'currentPage'
      - routePath: '/{news-title}'
        _controller: 'News::detail'
        _arguments:
          news-title: news
    defaultController: 'News::list'
    defaults:
      page: '1'
    requirements:
      page: '\d+'
    aspects:
      page-label:
        type: LocaleModifier
        default: 'page'
        localeMap:
          - locale: 'de_DE.*'
            value: 'seite'
      page:
        type: StaticRangeMapper
        start: '1'
        end: '100'
      news-title:
        type: NewsTitle

@froemken
Copy link
Contributor

froemken commented May 4, 2024

News has implemented a TypoScript configuration errorHandling. Here you can configure what should happen, if a news can not be found. To get that option working, a 404 request has to be transferred to that position. This is only possible, if a fallbackValue was added to the site config.yaml. Else: The 404 will be handled by TYPO3 site routing (This is, what you expect). As fallbackValue will be forgotten to set often, news implemented new aspect mappers which will set tableName, routeFieldName and fallbackValue automatically. Here, fallbackValue will be set to null if not explicit set in config.yaml.

The worst thing you can do is:

- routePath: '/{news-title}'
  _controller: 'News::detail'
  _arguments:
    news-title: news

Example:
You request URL: https://example.com/article/detail/new-typo3
The PageResolver of TYPO3 will detect https://example.com/article/detail as valid page. So the other part of the URL must be checked against new-typo3 in news table. If record was found, everything is good, if not, and fallbackValue is set in any kind, the errorHandling jumps in.

You request URL: https://example.com/article/fooNotFound
The PageResolver of TYPO3 will detect https://example.com/article as valid page. So the other part of the URL must be checked against fooNotFound in news table, because you have not defined any additional identifier in config.yaml to prevent such requests.

Please configure an additional identifier in config.yaml:

- routePath: '/news-detail/{news-title}'
  _controller: 'News::detail'
  _arguments:
    news-title: news

or reduce possible aspects with limitToPages. That way these aspect mappers will not be taken into account anymore.

As third option you can switch to "good old":

news-title:
  type: PersistedAliasMapper
  tableName: tx_news_domain_model_news
  routeFieldName: path_segment

As fallbackValue is NOT set, only the TYPO3 internal 404 handling will be used. The errorHandling option in TypoScript can NOT be reached anymore. Keep that in mind.

For me this is a configuration issue, but not a news issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants