#105322ConfigurationManager loads hidden sys_template in Backend context
Description
When fetching the TS configuration of a page in Backend context by utilizing the ConfigurationManager, sys_template entries in the rootline are loaded, even when they are hidden.
I stumbled across this because I had a hidden sys_template with sys_template.clear >0 in the rootline which prevented my site set TS from being loaded. After completely deleting the entry, the site set TS was loaded.
How to reproduce
Requirements
- fresh TYPO3 v13.4 installation
- a hidden sys_template placed on the root page with dummy TS setup
- a Backend Controller with the following code (tested within a class that extends the StandardContentPreviewRenderer)
$configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
$configuration = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
- optional: a site set dependency in the site config, which contains a setup.typoscript with dummy TS
When you debug $configuration on any page below the root page (or itself), you can see that the TS setup of the hidden sys_template is loaded by the ConfigurationManager. Having sys_template.clear >0, even prevents the site set from being loaded. After deleting the sys_template record completely, the site set TS setup is loaded again.
Reviews 1
History 24
-
Georg Ringer commented and changed Sprint Focus On Location Sprint <span data-processor="relativetime" data-value="2025-04-21T05:45:07+00:00" > 04/21/25, 05:45 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 89654 status
NewUnder Review <span data-processor="relativetime" data-value="2025-06-06T06:49:15+00:00" > 06/06/25, 06:49 </span> -
Gerrit Code Review pushed patch set 2 for main to change 89654 <span data-processor="relativetime" data-value="2025-06-06T08:53:38+00:00" > 06/06/25, 08:53 </span>
-
Stefan Froemken commented and changed status
Under ReviewClosed assigned to Stefan Froemken Sprint FocusOn Location Sprint<span data-processor="relativetime" data-value="2025-06-06T13:17:52+00:00" > 06/06/25, 13:17 </span>While working with TypoScript in the backend context is generally discouraged, TYPO3 Core still allows access via the Extbase ConfigurationManager, and therefore it remains a valid — though limited — use case.
One common pitfall in this context: In the TYPO3 backend, hidden records are not excluded by default — only deleted records are. This means that if you have a hidden sys_template record (which holds TypoScript), it will still be included when retrieving the TypoScript setup via:
$configuration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
This can lead to discrepancies compared to the frontend context, where hidden records are excluded.
If you want to retrieve the exact same TypoScript setup as the frontend would use, you must explicitly configure the Context to exclude hidden and time-restricted records before calling getConfiguration().
Here’s how you can do this properly inside an Extbase controller action, e.g. CarController::driveAction():
<?php use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Context\VisibilityAspect; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; class CarController extends ActionController { public function driveAction(): void { // Modify the context to simulate frontend visibility rules $context = GeneralUtility::makeInstance(Context::class); $context->setAspect( 'visibility', GeneralUtility::makeInstance(VisibilityAspect::class, false, false, false, false) ); // Now retrieve TypoScript as it would be evaluated in the frontend $setup = $this->configurationManager->getConfiguration( ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT ); // Resetting the context afterwards is highly recommended // (e.g., by restoring a previous state or reloading the aspect if needed) // ... use $setup as needed ... } }Important: After reading the configuration, you should reset or restore the Context visibility aspect to avoid unintentionally affecting other logic that may rely on the default backend behavior (which includes hidden records).
This way, the retrieved TypoScript is consistent with what would be available in the frontend, avoiding surprises caused by hidden or time-based templates being included during backend processing.
Hope that clears up the issue and helps others encountering similar scenarios!
I guess issue is in
\TYPO3\CMS\Core\TypoScript\IncludeTree\SysTemplateRepository::getSysTemplateQueryRestrictionContainer