Issue Bug Closed

#93609Wrong URL generated by router returned by sitefinder in scheduler task

Aimeos no-lastname-given 02/28/21, 08:28 updated 07/27/24, 14:16

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

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 4

  1. Georg Ringer commented and changed status New Needs Feedback 03/02/21, 17:47

    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> );
  2. Aimeos no-lastname-given commented 03/04/21, 13:18

    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.

  3. Christian Eßl commented 03/10/23, 06:09

    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)

  4. Georg Ringer commented and changed status Needs Feedback Closed 07/27/24, 14:16

    Hey Norbert,

    I am closing this issue as there are no plans to change the routing and as Christian pointed out, also in frontend it works out that way. if you don’t agree, feel free to contact me via slack!