Bug #72706

Manually instantiated UriBuilder is incomplete

Added by Aimeos no-lastname-given about 4 years ago. Updated 10 days ago.

Must have
Backend API
Target version:
Start date:
Due date:
% Done:


TYPO3 Version:
PHP Version:
Is Regression:
Sprint Focus:


When trying to instantiate the UriBuilder object in a scheduler task using the object manager, the resulting object is incomplete, esp. the ContentObjectRenderer instance is missing. This results in a fatal error when trying to generate a link.

Example code in scheduler task:

$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( \TYPO3\CMS\Extbase\Object\ObjectManager::class );
$uriBuilder = $objectManager->get( \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::class );

$uriBuilder->setTargetPageUid( $pageid )->setArguments( array() );
$url = $uriBuilder->buildFrontendUri();

It worked from 7.0 to at least 7.3 but seemed to vanish in 7.4 again.

Related issues

Related to TYPO3 Core - Bug #88506: Scheduler generated URLs contain absolute unix paths Closed 2019-06-06


#1 Updated by Christian Eßl 9 months ago

  • TYPO3 Version changed from 7 to 10

This is still an issue in master and the problem is pretty well known and clear:

You need a valid frontend context for the UriBuilder to be able to correctly call UriBuilder::buildFrontendUri(). This means you can't build frontend uris in backend or cli context.

There are several workarounds available like:
  • manually setting up a TypoScriptFrontendController for "simulating" the frontend (which is really ugly)
  • using third party extensions like "typoscript_rendering"

But since TYPO3 9.5, the new Routing API is available and already used in other parts in the core (Have a look at BackendUtility::getPreviewUrl()). I wonder if the routing API could be used in the UriBuilder as well for easily building frontend uris independent of the callers context? Or are there some edge cases or other issues that could arise from that?

#2 Updated by Benni Mack about 2 months ago

  • Status changed from New to Needs Feedback

Since TYPO3 v9 / site handling you don't need TSFE or cObject anymore to generate a link to a page.


This works in CLI and Backend environment as well.

#3 Updated by Aimeos no-lastname-given about 2 months ago

Thanks a lot!
How do we get the $site variable? Can you post the code that is necessary for setting it up that?

#4 Updated by Benni Mack about 1 month ago

In TYPO3 v9, try out the SiteFinder class, there is a class "getSiteByPageId($pid)".

        $pageId = 13;
        $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId($pageId);
        $site->getRouter()->generateUri($pageId, ['my-argument' => 13]);

#5 Updated by Benni Mack about 1 month ago

  • Related to Bug #88506: Scheduler generated URLs contain absolute unix paths added

#6 Updated by Georg Ringer 10 days ago

  • Status changed from Needs Feedback to Resolved

setting this as solved

Also available in: Atom PDF