Project

General

Profile

Actions

Bug #87087

closed

StaticRouteResolver ignores additional parameters

Added by F Altrock over 5 years ago. Updated over 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

Also available in: Atom PDF