Project

General

Profile

Actions

Bug #93609

open

Wrong URL generated by router returned by sitefinder in scheduler task

Added by Aimeos no-lastname-given over 3 years ago. Updated over 1 year ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
scheduler
Target version:
-
Start date:
2021-02-28
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
scheduler, router, multi site
Complexity:
Is Regression:
Sprint Focus:

Description

Given the following page tree:

site1 (site configuration "site1" with domain test.com)
- page1
- page2

site2 (site configuration "site2" with domain example.org)
- page3
- page4

When retrieving the router for page4 in a scheduler task and generating an URL for page3, the site router returns an URL for page1 when using this code:

$siteFinder = GeneralUtility::makeInstance( SiteFinder::class );
$router = $$siteFinder->getSiteByPageId( <ID page4> )->getRouter();
$url = $router->generateUri( <ID page3> );

Result: https://test.com/page1
Expected: https://example.org/page3

Actions #1

Updated by Georg Ringer over 3 years ago

  • Status changed from New to Needs Feedback

the PageRouter is always bound to the given site. So my question is: why don't you use

$siteFinder = GeneralUtility::makeInstance( SiteFinder::class );
$router = $$siteFinder->getSiteByPageId( <ID page3> )->getRouter();
$url = $router->generateUri( <ID page3> );

Actions #2

Updated by Aimeos no-lastname-given over 3 years ago

We need to create several page URLs within one site and choose the first page ID to get the router for the site. Creating URLs in the frontend also doesn't require to get the router for every page separately so I would expect it shouls work in the scheduler task the same way.

Actions #3

Updated by Christian Eßl over 1 year ago

Internally, it's the same in the frontend. If you create a link to a typo3 page (from viewhelper, typoscript, LinkFactory, etc.), the linkbuilding will then be passed to PageLinkBuilder, which itself uses the SiteFinder class to fetch the corresponding site to the page id. The router of this site object is then used to finally create the uri.
There is never a case, where the router of another site, that the page id does not belong to, is used to create an uri. (This would create wrong uris)

Actions

Also available in: Atom PDF