Commit ed0912e0 authored by Andreas Fernandez's avatar Andreas Fernandez
Browse files

[BUGFIX] Use generated TSFE in PageLinkBuilder

If the PageLinkBuilder is invoked with a non-available TSFE as e.g. in
the "Redirects" module, generating the URLs to pages with a fragment,
e.g. to a referenced content element, works now as we're using the
TSFE generated within PageLinkBuilder itself.

Resolves: #96101
Releases: main, 11.5
Change-Id: I481b7d8573424dab59df22b0d81a734e03b70575
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72776


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent a8b9eefb
......@@ -406,6 +406,7 @@ class PageLinkBuilder extends AbstractTypolinkBuilder
*/
protected function generateUrlForPageWithSiteConfiguration(array $page, Site $siteOfTargetPage, array $queryParameters, string $fragment, array $conf): UriInterface
{
$tsfe = $this->getTypoScriptFrontendController();
$currentSite = $this->getCurrentSite();
$currentSiteLanguage = $this->getCurrentSiteLanguage();
// Happens when currently on a pseudo-site configuration
......@@ -438,9 +439,9 @@ class PageLinkBuilder extends AbstractTypolinkBuilder
if ($fragment
&& $useAbsoluteUrl === false
&& $currentSiteLanguage === $siteLanguageOfTargetPage
&& $targetPageId === (int)$GLOBALS['TSFE']->id
&& $targetPageId === (int)$tsfe->id
&& (empty($conf['addQueryString']) || !isset($conf['addQueryString.']))
&& !($GLOBALS['TSFE']->config['config']['baseURL'] ?? false)
&& !($tsfe->config['config']['baseURL'] ?? false)
&& count($queryParameters) === 1 // _language is always set
) {
$uri = (new Uri())->withFragment($fragment);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment