Project

General

Profile

Bug #102892 » record-linkbuilder-missing-typoscript-fix.diff

Ramon Zöllner, 2024-11-20 10:56

View differences:

Classes/Typolink/DatabaseRecordLinkBuilder.php 2024-10-04 10:31:50
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\TypoScriptAspect;
use TYPO3\CMS\Core\LinkHandling\TypoLinkCodecService;
use TYPO3\CMS\Core\Site\Entity\NullSite;
use TYPO3\CMS\Core\TypoScript\PageTsConfig;
......
$request = $this->contentObjectRenderer->getRequest();
$pageTsConfig = $this->getPageTsConfig($tsfe, $request);
$configurationKey = $linkDetails['identifier'] . '.';
$typoScriptArray = $request->getAttribute('frontend.typoscript')?->getSetupArray() ?? [];
try {
$typoScriptArray = $request->getAttribute('frontend.typoscript')?->getSetupArray() ?? [];
} catch (\RuntimeException $e) {
if ($e->getCode() != 1666513645) {
throw $e;
}
//An exception is thrown when TypoScript setup array is not available.
$typoScriptArray = $this->getFullTypoScript($tsfe, $request);
}
$configuration = $typoScriptArray['config.']['recordLinks.'] ?? [];
$linkHandlerConfiguration = $pageTsConfig['TCEMAIN.']['linkHandler.'] ?? [];
......
$runtimeCache->set('pageTsConfig-' . $id, $pageTsConfig);
return $pageTsConfig->getPageTsConfigArray();
}
/**
* Helper method to load full typoscript when in cached context.
* @see https://github.com/derhansen/fe_change_pwd/commit/3bb4181c8973c63458dd450a0219804e7d5496b9
*/
protected function getFullTypoScript(TypoScriptFrontendController $tsfe, ServerRequestInterface $request): array
{
GeneralUtility::makeInstance(Context::class)
->setAspect('typoscript', GeneralUtility::makeInstance(TypoScriptAspect::class, true));
$requestWithFullTypoScript = $tsfe->getFromCache($request);
$fullTypoScript = $requestWithFullTypoScript->getAttribute('frontend.typoscript')->getSetupArray() ?? [];
return $fullTypoScript;
}
}
(2-2/2)