#108178Redirect with anchor breaks redirect backend module
Description
Creating a redirect which leads to an anchor of a page breaks the Redirect backend module.
The hashtag of the anchor in the database field `target` seems to create the problem.
I guess the link creation within the view for the column “Target” fails.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Files 1
History 7
-
Georg Ringer commented and changed attached Bildschirmfoto 2025-11-19 um 21.02.26.png status
NewNeeds Feedback <span data-processor="relativetime" data-value="2025-11-19T20:03:37+00:00" > 11/19/25, 20:03 </span> -
Gerald Rintisch commented <span data-processor="relativetime" data-value="2025-11-20T06:26:46+00:00" > 11/20/25, 06:26 </span>
I tested again and can see that I missed something: The reason is the multilanguage-setup (single tree).
Links that are automatically created are something like
t3://page?uid=247&_language=0
If I manually create a link to an anchor it becomes something like
t3://page?uid=48#159
→ That breaks the module.
To fix that I need to adapt the link in the database to
t3://page?uid=48#159&_language=0
It follows the stack trace (shortened but I would say that’s the relevant part):
(1/1)Error
Call to a member function getContentFromPid() on null
in /var/www/html/vendor/typo3/cms-frontend/Classes/ContentObject/ContentObjectRenderer.php line 5010{
$queryBuilder = $connection->createQueryBuilder();
$expressionBuilder = $queryBuilder->expr();
$request = $this->getRequest();
$contentPid = $request->getAttribute(‘frontend.page.information’)->getContentFromPid();
$constraints = [];
$pid_uid_flag = 0;
$enableFieldsIgnore = [];
$queryParts = [at TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->getQueryConstraints()
in /var/www/html/vendor/typo3/cms-frontend/Classes/ContentObject/ContentObjectRenderer.php line 4892if ((string)($conf[‘pidInList’] ?? ‘’) === ‘’) {
$conf[‘pidInList’] = ‘this’;
}$queryParts = $this->getQueryConstraints($connection, $table, $conf);$queryBuilder = $connection->createQueryBuilder();
//todo Check against getQueryConstraints, can probably use FrontendRestrictionstodo here and remove enableFields there.
//at TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->getQuery()
in /var/www/html/vendor/typo3/cms-frontend/Classes/ContentObject/ContentObjectRenderer.php line 4754*/
public function exec_getQuery($table, $conf)
{
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table);
$statement = $this->getQuery($connection, $table, $conf);return $connection->executeQuery($statement);
}at TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->exec_getQuery()
in /var/www/html/vendor/typo3/cms-frontend/Classes/ContentObject/ContentObjectRenderer.php line 4772public function getRecords($tableName, array $queryConfiguration)
{
$records = [];$statement = $this->exec_getQuery($tableName, $queryConfiguration);$pageRepository = $this->getPageRepository();
while ($row = $statement->fetchAssociative()) {
// Versioning preview:at TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->getRecords()
in /var/www/html/vendor/sebkln/content-slug/Classes/Listener/ModifyFragment.php line 64];/** @var ContentObjectRenderer $recordContentObjectRenderer */
$recordContentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class);
$record = current($recordContentObjectRenderer->getRecords(‘tt_content’, $queryConfiguration));if (is_array($record)) {
// 4. Process the new fragment:
if (!$checkForHiddenHeaders || (int)$record[‘header_layout’] !== 100) {at Sebkln\ContentSlug\Listener\ModifyFragment->__invoke()
in /var/www/html/vendor/typo3/cms-core/Classes/EventDispatcher/EventDispatcher.php line 49if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) {
return $event;
}
foreach ($this->listenerProvider->getListenersForEvent($event) as $listener) {
$listener($event);
if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) {
break;
}
}at TYPO3\CMS\Core\EventDispatcher\EventDispatcher->dispatch()
in /var/www/html/vendor/typo3/cms-adminpanel/Classes/Service/EventDispatcher.php line 40$this->dispatchedEvents[$eventClass]++;
} else {
$this->dispatchedEvents[$eventClass] = 1;
}
return parent::dispatch($event);
}
}at TYPO3\CMS\Adminpanel\Service\EventDispatcher->dispatch()
in /var/www/html/vendor/typo3/cms-frontend/Classes/Typolink/PageLinkBuilder.php line 108$queryParameters[‘MP’] = $mountPointParameter;
}$event = new ModifyPageLinkConfigurationEvent($conf, $linkDetails, $page, $queryParameters, $fragment);
$event = GeneralUtility::makeInstance(EventDispatcherInterface::class)->dispatch($event);
$conf = $event->getConfiguration();
$page = $event->getPage();
$queryParameters = $event->getQueryParameters();
$fragment = $event->getFragment();at TYPO3\CMS\Frontend\Typolink\PageLinkBuilder->build()
in /var/www/html/vendor/typo3/cms-frontend/Classes/Typolink/LinkFactory.php line 149// records set links.
$contentObjectRenderer->getTypoScriptFrontendController() instanceof TypoScriptFrontendController ? $contentObjectRenderer->getTypoScriptFrontendController() : null
);
try {
return $linkBuilder->build($linkDetails, $linkText, $target, $linkConfiguration);
} catch (UnableToLinkException $e) {
$this->logger->debug(‘Unable to link “{text}”’, [
‘text’ => $e->getLinkText(),
‘exception’ => $e,at TYPO3\CMS\Frontend\Typolink\LinkFactory->buildLinkResult()
in /var/www/html/vendor/typo3/cms-frontend/Classes/Typolink/LinkFactory.php line 85if ($linkDetails === null) {
throw new UnableToLinkException(‘Could not resolve link details from ‘ . $linkParameter, 1642001442, null, $linkText);
}$linkResult = $this->buildLinkResult($linkText, $linkDetails, $target, $linkConfiguration, $contentObjectRenderer);// Enrich the link result with resolved attributes and run post processing
$linkResult = $this->addAdditionalAnchorTagAttributes($linkResult, $linkConfiguration, $contentObjectRenderer);at TYPO3\CMS\Frontend\Typolink\LinkFactory->create()
in /var/www/html/vendor/typo3/cms-frontend/Classes/ContentObject/ContentObjectRenderer.php line 4397public function createLink(string $linkText, array $conf): LinkResultInterface
{
$this->lastTypoLinkResult = null;
try {
$linkResult = GeneralUtility::makeInstance(LinkFactory::class)->create($linkText, $conf, $this);
} catch (UnableToLinkException $e) {
// URL could not be generated
throw $e;
}at TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->createLink()
in /var/www/html/vendor/typo3/cms-frontend/Classes/ContentObject/ContentObjectRenderer.php line 4419*/
public function createUrl(array $conf): string
{
try {
return $this->createLink(‘’, $conf)->getUrl();
} catch (UnableToLinkException $e) {
// URL could not be generated
return ‘’;
}at TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->createUrl()
in /var/www/html/vendor/typo3/cms-fluid/Classes/ViewHelpers/Uri/TypolinkViewHelper.php line 92$contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
if ($request) {
$contentObject->setRequest($request);
}
return $contentObject->createUrl($instructions);
}/** * Merges view helper arguments with typolink parts.at TYPO3\CMS\Fluid\ViewHelpers\Uri\TypolinkViewHelper::invokeContentObjectRenderer()
in /var/www/html/vendor/typo3/cms-fluid/Classes/ViewHelpers/Uri/TypolinkViewHelper.php line 65$request = null;
if ($this->renderingContext->hasAttribute(ServerRequestInterface::class)) {
$request = $this->renderingContext->getAttribute(ServerRequestInterface::class);
}
return $typolink !== ‘’ ? self::invokeContentObjectRenderer($this->arguments, $typolink, $request) : ‘’;
}protected static function invokeContentObjectRenderer(array $arguments, string $typoLinkParameter, ?ServerRequestInterface $request): string
{at TYPO3\CMS\Fluid\ViewHelpers\Uri\TypolinkViewHelper->render()
in /var/www/html/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php line 270);
}
$this->initialize();return $this->render();
}/** * Initializes the view helper before invoking the render method. -
Georg Ringer commented <span data-processor="relativetime" data-value="2025-11-20T20:21:39+00:00" > 11/20/25, 20:21 </span>
can you please test without the content-slug extension?
-
Gerald Rintisch commented <span data-processor="relativetime" data-value="2025-11-21T06:08:47+00:00" > 11/21/25, 06:08 </span>
You are right, that triggered the error. I did not read the stack trace properly. So sorry for that! Can be closed
-
Gerald Rintisch commented <span data-processor="relativetime" data-value="2025-11-21T06:53:49+00:00" > 11/21/25, 06:53 </span>
I would like to support the extension author with some more information. The problem seems to be that $recordContentObjectRenderer->getRecords() in the backend cannot be used as it’s using $request->getAttribute(‘frontend.page.information’) later on which seems to need frontend context.
Do you right know right away how the extension could get the record in another way?
-
Rafael Kähm commented <span data-processor="relativetime" data-value="2025-12-05T09:58:45+00:00" > 12/05/25, 09:58 </span>
Is it possible to apply and port following patch up to TYPO3 12?
diff --git a/Classes/Event/ModifyPageLinkConfigurationEvent.php b/Classes/Event/ModifyPageLinkConfigurationEvent.php --- a/Classes/Event/ModifyPageLinkConfigurationEvent.php +++ b/Classes/Event/ModifyPageLinkConfigurationEvent.php @@ -17,6 +17,8 @@ namespace TYPO3\CMS\Frontend\Event; +use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; + /** * A generic PSR 14 Event to allow modifying the incoming (and resolved) page when building a "page link". * @@ -32,7 +34,8 @@ private readonly array $linkDetails, private array $page, private array $queryParameters, - private string $fragment + private string $fragment, + private ContentObjectRenderer $contentObjectRenderer, ) {} public function getConfiguration(): array @@ -85,4 +88,9 @@ { return $this->pageWasModified; } + + public function getContentObjectRenderer(): ContentObjectRenderer + { + return $this->contentObjectRenderer; + } } diff --git a/Classes/Typolink/PageLinkBuilder.php b/Classes/Typolink/PageLinkBuilder.php --- a/Classes/Typolink/PageLinkBuilder.php +++ b/Classes/Typolink/PageLinkBuilder.php @@ -87,7 +87,14 @@ $queryParameters['MP'] = $mountPointParameter; } - $event = new ModifyPageLinkConfigurationEvent($conf, $linkDetails, $page, $queryParameters, $fragment); + $event = new ModifyPageLinkConfigurationEvent( + $conf, + $linkDetails, + $page, + $queryParameters, + $fragment, + $this->contentObjectRenderer, + ); $event = GeneralUtility::makeInstance(EventDispatcherInterface::class)->dispatch($event); $conf = $event->getConfiguration(); $page = $event->getPage();Background:
Collision of EXT:solr and EXT:content_slug.
Patch for EXT:content_slug v4.3.0, allowing EXT:solr to get the URLs properly:
diff --git a/Classes/Listener/ModifyFragment.php b/Classes/Listener/ModifyFragment.php --- a/Classes/Listener/ModifyFragment.php +++ b/Classes/Listener/ModifyFragment.php @@ -38,7 +38,7 @@ $fragment = $event->getFragment(); $fragment = substr($fragment, 1); - if (is_numeric($fragment) && !empty($fragment) && $this->isFrontendRequest()) { + if (is_numeric($fragment) && !empty($fragment) && $this->isFrontendRequest($event)) { // 1. Get TypoScript configuration: $settings = $this->configurationManager->getConfiguration( ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT @@ -57,7 +57,7 @@ ]; /** @var ContentObjectRenderer $recordContentObjectRenderer */ - $recordContentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class); + $recordContentObjectRenderer = $event->getContentObjectRenderer(); $record = current($recordContentObjectRenderer->getRecords('tt_content', $queryConfiguration)); if (is_array($record)) { @@ -77,13 +77,13 @@ } } - protected function isFrontendRequest(): bool + protected function isFrontendRequest(ModifyPageLinkConfigurationEvent $event): bool { - if (($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface - && ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend() + if (($event->getContentObjectRenderer()->getRequest() ?? null) instanceof ServerRequestInterface + && ApplicationType::fromRequest($event->getContentObjectRenderer()->getRequest())->isFrontend() ) { return true; } return false; } -} +}Indexing url field requires then:
typolink { parameter = t3://page?uid={field:pid}#c{field:uid} parameter.insertData = 1 returnLast = url forceAbsoluteUrl = 1 } -
Georg Ringer commented and changed status
Needs FeedbackClosed <span data-processor="relativetime" data-value="2026-10-15T11:49:41+00:00" > 10/15/26, 11:49 </span>solved with #110109
Thanks for creating the issue!
I tested it on latest 13.4.20-dev and works for me
Bildschirmfoto%202025-11-19%20um%2021.02.26.png
can you please test on local version as well, or maybe on a different setup and still an error happens, provide at least a stacktrace?
thanks!