diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85666-TypoScriptFrontendController-initTemplate.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85666-TypoScriptFrontendController-initTemplate.rst new file mode 100644 index 0000000000000000000000000000000000000000..2975510f8c44d523048b91d4f7169d87c7c28348 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85666-TypoScriptFrontendController-initTemplate.rst @@ -0,0 +1,33 @@ +.. include:: ../../Includes.txt + +================================================================ +Deprecation: #85666 - TypoScriptFrontendController->initTemplate +================================================================ + +See :issue:`85666` + +Description +=========== + +The method :php:`TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->initTemplate()` has been marked as +deprecated. + + +Impact +====== + +Calling the method directly will trigger a deprecation message. + + +Affected Installations +====================== + +TYPO3 installations with custom extensions calling this public method directly. + + +Migration +========= + +The method call can simply get removed, the TemplateService in instantiated by TSFE on demand. + +.. index:: Frontend, PHP-API, FullyScanned, ext:frontend diff --git a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php index 2a98a13614d5bb522d8715146c78fca0247e3e25..3558dd80f59cfd9719e4e99b42d198ae245fb42f 100644 --- a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php +++ b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php @@ -2237,9 +2237,11 @@ class TypoScriptFrontendController implements LoggerAwareInterface /** * Initialize the TypoScript template parser + * @deprecated since TYPO3 v9.4 will be removed in TYPO3 v10.0. Either instantiate $TSFE->tmpl yourself, if really necessary. */ public function initTemplate() { + trigger_error('TSFE->initTemplate() will be removed in TYPO3 v10.0. Instantiating TemplateService is done implicitly on usage within TSFE directly.', E_USER_DEPRECATED); $this->tmpl = GeneralUtility::makeInstance(TemplateService::class, $this->context); } @@ -2262,6 +2264,10 @@ class TypoScriptFrontendController implements LoggerAwareInterface return; } + if (!($this->tmpl instanceof TemplateService)) { + $this->tmpl = GeneralUtility::makeInstance(TemplateService::class, $this->context); + } + $pageSectionCacheContent = $this->tmpl->getCurrentPageData(); if (!is_array($pageSectionCacheContent)) { // Nothing in the cache, we acquire an "exclusive lock" for the key now. @@ -2477,6 +2483,10 @@ class TypoScriptFrontendController implements LoggerAwareInterface */ public function getConfigArray() { + if (!($this->tmpl instanceof TemplateService)) { + $this->tmpl = GeneralUtility::makeInstance(TemplateService::class, $this->context); + } + // If config is not set by the cache (which would be a major mistake somewhere) OR if INTincScripts-include-scripts have been registered, then we must parse the template in order to get it if (empty($this->config) || is_array($this->config['INTincScript']) || $this->forceTemplateParsing) { $timeTracker = $this->getTimeTracker(); diff --git a/typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php b/typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php index ac875ea632dc21d3d1f04ef37d16c47ac2a921ac..dd57e6ce25300fd9514bf8c45f2fd94566d0aad5 100644 --- a/typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php +++ b/typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php @@ -56,10 +56,6 @@ class PrepareTypoScriptFrontendRendering implements MiddlewareInterface */ public function process(ServerRequestInterface $request, PsrRequestHandlerInterface $handler): ResponseInterface { - // Starts the template - $this->timeTracker->push('Start Template'); - $this->controller->initTemplate(); - $this->timeTracker->pull(); // Get from cache $this->timeTracker->push('Get Page from cache'); // Locks may be acquired here diff --git a/typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php b/typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php index 6129469e16996db5dae755404df8f116847c9ef0..635290d551b6cf7616b14e786a88a96439776bd8 100644 --- a/typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php +++ b/typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Frontend\Typolink; */ use TYPO3\CMS\Core\Service\DependencyOrderingService; +use TYPO3\CMS\Core\TypoScript\TemplateService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; @@ -200,7 +201,7 @@ abstract class AbstractTypolinkBuilder (int)GeneralUtility::_GP('type') ); $GLOBALS['TSFE']->sys_page = GeneralUtility::makeInstance(PageRepository::class); - $GLOBALS['TSFE']->initTemplate(); + $GLOBALS['TSFE']->tmpl = GeneralUtility::makeInstance(TemplateService::class); } return $GLOBALS['TSFE']; } diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php index 7f014b77ccba5f4b29491aef55c5f0caa7b2e543..4b88e9588a4e4b01b3e6d20d8495e5b41e4682da 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php @@ -2487,4 +2487,11 @@ return [ 'Deprecation-85554-PageRepository-checkWorkspaceAccess.rst', ], ], + 'TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->initTemplate' => [ + 'numberOfMandatoryArguments' => 0, + 'maximumNumberOfArguments' => 0, + 'restFiles' => [ + 'Deprecation-85666-TypoScriptFrontendController-initTemplate.rst', + ], + ], ]; diff --git a/typo3/sysext/redirects/Classes/Service/RedirectService.php b/typo3/sysext/redirects/Classes/Service/RedirectService.php index 9593c42f13a724743e8327bf4398e0ade2e490a0..3472fde447d6cf04bbf58ffa88be608a51c7f0e0 100644 --- a/typo3/sysext/redirects/Classes/Service/RedirectService.php +++ b/typo3/sysext/redirects/Classes/Service/RedirectService.php @@ -247,7 +247,6 @@ class RedirectService implements LoggerAwareInterface GeneralUtility::_GP('type') ); $GLOBALS['TSFE']->fetch_the_id(); - $GLOBALS['TSFE']->initTemplate(); $GLOBALS['TSFE']->getConfigArray(); $GLOBALS['TSFE']->settingLanguage(); $GLOBALS['TSFE']->settingLocale();