Bug #87817

PageLinkBuilder fails adding pagetype parameter, if routeEnhancers for PageTypeSuffix is defined

Added by Philipp Seiler over 1 year ago. Updated 3 months ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Target version:
-
Start date:
2019-03-01
Due date:
% Done:

100%

TYPO3 Version:
9
PHP Version:
Tags:
routing,enhancer,sitemap,seo
Complexity:
Is Regression:
Sprint Focus:

Description

  • Define a RouteEnhancer for a certain page type:
    routeEnhancers:
      PageTypeSuffix:
        type: PageType
        default: ''
        map:
          foo: 1234
  • Call some method that uses TYPO3\CMS\Frontend\Typolink\PageLinkBuilder, including a typeNum as parameter.
    <f:uri.page pageType="{type}" additionalParams="{sitemap: sitemap.key, page: sitemap.page}" absolute="true" noCacheHash="false" />
    $uri = $uriBuilder->setTargetPageUid($pageUid)->setTargetPageType($pageType)->build();
  • The typeNum used in the example code above should NOT be registered in the RouteEnhancers. E.g. '5678' to fit the defined RouteEnhancer above.
  • TYPO3 then tries to use \TYPO3\CMS\Core\Routing\Enhancer\PageTypeDecorator to add the defined page type in the RouteEnhancers to the URL, although for the selected typeNum ('5678') there is no RouteEnhancer defined.
  • This leads to method decorateForGeneration() removing the typeNum:
    $deflatedParameters = $existingRoute->getOption('deflatedParameters') ?? $parameters;
    if (isset($deflatedParameters['type'])) {
        unset($deflatedParameters['type']);
        $existingRoute->setOption(
            'deflatedParameters',
            $deflatedParameters
        );
    }
  • Results in a link without typeNum added to it.

I stumbled across this, when defining a RouteEnhancer for a typeNum I used in a plugin. I also had the TYPO3 seo-extension installed, which defines the typeNum 1533906435 for getting the sitemaps. However the sitmap extension didn't create valid URLs with typeNums, and were therefore useless.

A quick fix is, to also add the typeNum defined by the seo-extension to the RouteEnhancers:

routeEnhancers:
  PageTypeSuffix:
    type: PageType
    default: ''
    map:
      foo: 1234
      sitemap: 1533906435


Related issues

Related to TYPO3 Core - Bug #87087: StaticRouteResolver ignores additional parameters Closed 2018-12-05
Related to TYPO3 Core - Bug #86835: Static route sitemap.xml is still not working on single-page tree New 2018-11-02
Related to TYPO3 Core - Bug #88836: page type not respected under some circumstances Closed 2019-07-24
Related to TYPO3 Core - Bug #87087: StaticRouteResolver ignores additional parameters Closed 2018-12-05
Related to TYPO3 Core - Bug #87016: Seo sitemap does not note routeEnhancer on extensions Closed 2018-11-27
Related to TYPO3 Core - Bug #87104: PageTypeSuffix removes type parameter for non mapped type values Needs Feedback 2018-12-07

Associated revisions

Revision 8bb73e3f (diff)
Added by Benni Mack 5 months ago

[BUGFIX] Allow resolving unmapped type GET parameters with PageTypeDecorator

When the PageTypeDecorator is used for routing, currently ALL available
typeNums must be registered, otherwise links to pages with a typeNum
just get their type removed (fallback to default).

A new check is added when creating links (resolving these URLs with
a GET type= parameter works just fine) for skipping unmapped arguments
when decorating.

Resolves: #87817
Resolves: #88836
Releases: master, 9.5
Change-Id: I252cf80de2befed8396cc93b1bc737d77aa18b31
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62383
Tested-by: TYPO3com <>
Tested-by: Henning Liebe <>
Tested-by: Susanne Moog <>
Tested-by: Daniel Goerz <>
Reviewed-by: Henning Liebe <>
Reviewed-by: Susanne Moog <>
Reviewed-by: Daniel Goerz <>

Revision 1d352d19 (diff)
Added by Benni Mack 5 months ago

[BUGFIX] Allow resolving unmapped type GET parameters with PageTypeDecorator

When the PageTypeDecorator is used for routing, currently ALL available
typeNums must be registered, otherwise links to pages with a typeNum
just get their type removed (fallback to default).

A new check is added when creating links (resolving these URLs with
a GET type= parameter works just fine) for skipping unmapped arguments
when decorating.

Resolves: #87817
Resolves: #88836
Releases: master, 9.5
Change-Id: I252cf80de2befed8396cc93b1bc737d77aa18b31
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62811
Tested-by: TYPO3com <>
Tested-by: Henning Liebe <>
Tested-by: Daniel Goerz <>
Reviewed-by: Henning Liebe <>
Reviewed-by: Daniel Goerz <>

History

#1 Updated by Tim Karliczek about 1 year ago

I am able to reproduce this behaviour in Typo3 9.5.5.

#2 Updated by Philipp Seiler about 1 year ago

  • Description updated (diff)

#3 Updated by Sebastian Mazza about 1 year ago

I am also able to reproduce this behaviour in Typo3 9.5.5.
(unfortunately my workaround list will be much longer)

#4 Updated by Falk no-lastname-given about 1 year ago

I've spent hours to find the same issue in 9.5.6

#5 Updated by Christian Ducrot 8 months ago

Still exists in 9.5.10

#6 Updated by Tymoteusz Motylewski 7 months ago

  • Related to Bug #87087: StaticRouteResolver ignores additional parameters added

#7 Updated by Tymoteusz Motylewski 7 months ago

  • Related to Bug #86835: Static route sitemap.xml is still not working on single-page tree added

#8 Updated by Tymoteusz Motylewski 7 months ago

  • Related to Bug #88836: page type not respected under some circumstances added

#9 Updated by Tymoteusz Motylewski 7 months ago

  • Related to Bug #87087: StaticRouteResolver ignores additional parameters added

#10 Updated by Tymoteusz Motylewski 7 months ago

  • Related to Bug #87016: Seo sitemap does not note routeEnhancer on extensions added

#11 Updated by Gerrit Code Review 7 months ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62383

#12 Updated by Gerrit Code Review 7 months ago

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62383

#13 Updated by Gerrit Code Review 7 months ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62383

#14 Updated by Gerrit Code Review 5 months ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62383

#15 Updated by Gerrit Code Review 5 months ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62811

#16 Updated by Benni Mack 5 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#17 Updated by Benni Mack 3 months ago

  • Status changed from Resolved to Closed

#18 Updated by Benni Mack 3 months ago

  • Related to Bug #87104: PageTypeSuffix removes type parameter for non mapped type values added

Also available in: Atom PDF