Project

General

Profile

Actions

Bug #87087

closed

StaticRouteResolver ignores additional parameters

Added by F Altrock over 5 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2018-12-05
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:
On Location Sprint

Description

Use case: I want to have a static route sitemap.xml that shows the result of ?type=1533906435&sitemap=pages,
which is the sitemap XML for a particular site.

Adding the parameters either directly to a t3://page? URI or via the link wizard in "Additional link parameters"
results in the renderIndex method of the XmlSitemapRenderer to be invoked, instead of renderSitemap...

As it turns out, the StaticRouteResolver "sees" the additional parameter by parsing the typoLink through
LinkService, but they are returned opaquely as the "parameters" key, in the form sitemap=pages.
When the target URL of the static route is resolved, this value is ignored, and generateUri of the PageRouter
also cannot understand additional parameters in that way.

The relevant piece of code:
https://github.com/TYPO3-CMS/frontend/blob/d896e39da04ce86a2d179e1f5535737114130005/Classes/Middleware/StaticRouteResolver.php#L105-L113

protected function getPageUri(ServerRequestInterface $request, Site $site, array $urlParams): string
{
    $uri = $site->getRouter()->generateUri(
        (int)$urlParams['pageuid'],
        ['type' => $urlParams['pagetype'] ?? 0, '_language' => $request->getAttribute('language', null)],
        '',
        RouterInterface::ABSOLUTE_URL
    );
    return (string)$uri;
}

Using parse_str on the extracted query string and merging the result into the parameters for generateUri
fixes my particular use case:

protected function getPageUri(ServerRequestInterface $request, Site $site, array $urlParams): string
{
    parse_str($urlParams['parameters'] ?: '', $extraParams);
    $uri = $site->getRouter()->generateUri(
        (int)$urlParams['pageuid'],
        array_merge(
            ['type' => $urlParams['pagetype'] ?? 0, '_language' => $request->getAttribute('language', null)],
            $extraParams
        ),
        '',
        RouterInterface::ABSOLUTE_URL
    );
    return (string)$uri;
}

Unfortunately I have no real clue about how to make this a proper patch with Tests.


Related issues 4 (1 open3 closed)

Related to TYPO3 Core - Bug #87817: PageLinkBuilder fails adding pagetype parameter, if routeEnhancers for PageTypeSuffix is definedClosed2019-03-01

Actions
Related to TYPO3 Core - Bug #86835: Static route sitemap.xml is still not working on single-page treeNew2018-11-02

Actions
Related to TYPO3 Core - Bug #87817: PageLinkBuilder fails adding pagetype parameter, if routeEnhancers for PageTypeSuffix is definedClosed2019-03-01

Actions
Related to TYPO3 Core - Bug #87016: Seo sitemap does not note routeEnhancer on extensionsClosed2018-11-27

Actions
Actions #1

Updated by Josef Glatz over 5 years ago

Just as a reference: according to the Feature Description https://docs.typo3.org/typo3cms/extensions/core/latest/Changelog/9.5/Feature-86214-ImplementStaticRoutes.html#implementation of the core: parameters are not available there – the matching is done solely on the path level.

Actions #2

Updated by F Altrock over 5 years ago

Well yes, matching on the parameters is way too complex. That's not what I'm after though:
My use case is a static route of a simple path "sitemap.xml" and I need the target URL to
have additional parameters. If the Site configuration form offers me the default typoLink
wizard for this field, then I should be able to use all fields. Sure, class, target, and
title make no sense for a route, but parameters do.

Actions #3

Updated by Tymoteusz Motylewski over 4 years ago

  • Related to Bug #87817: PageLinkBuilder fails adding pagetype parameter, if routeEnhancers for PageTypeSuffix is defined added
Actions #4

Updated by Tymoteusz Motylewski over 4 years ago

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

Updated by Tymoteusz Motylewski over 4 years ago

  • Related to Bug #87817: PageLinkBuilder fails adding pagetype parameter, if routeEnhancers for PageTypeSuffix is defined added
Actions #6

Updated by Tymoteusz Motylewski over 4 years ago

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

Updated by Susanne Moog over 4 years ago

  • Sprint Focus set to On Location Sprint
Actions #8

Updated by Gerrit Code Review over 4 years 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/+/62891

Actions #9

Updated by Gerrit Code Review over 4 years 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/+/62911

Actions #10

Updated by Benni Mack over 4 years ago

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

Updated by Benni Mack about 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF