#108428Backend TypoScript evaluation ignores TypoScript root and strips includes
Description
Summary
Backend TypoScript evaluation uses the global rootline even when the site is marked as a TypoScript root, while the frontend scopes the rootline to the current site. Both contexts share the same per-template TypoScript cache (sys-template-setup-<hash>.php), so backend evaluation can drop includes needed by the frontend.</hash>
Affected versions / environment
- TYPO3 v14.0.x (base distribution), PHP 8.4 platform; reproducible on a clean install with site sets and a TypoScript root site.
- Also reproduced on TYPO3 13.4 LTS.
- Likely affects main as the FE/BE rootline handling is unchanged there.
Prerequisites / setup
- Page tree (both sites have “Use as Root Page” set and are TYPO3 sites with the same site set):
* [root]
* Site A
* Site B
* Includes (folder)
- Site set included by Site A and Site B:
name: smic/typoscript-bug
label: Default site set for the typoscript_bug package
page = PAGE
page {
10 = TEXT
10.value = <p>Hello, from the site set!</p>
}
- TypoScript records:
** Site A: TypoScript record with
page.20 = TEXT
page.20.value = <p>Hello, from the site TypoScript record.</p>
and basedOn pointing to a shared TypoScript record on the Includes page:
page.30 = TEXT
page.30.value = <p>Hello, from the TypoScript include.</p>
** Site B: identical TypoScript record (same content and same basedOn to the Includes page record).
- Backend trigger setup:
** Create a blank Form in the Forms module.
** Place a “Form” content element on Site B, select that form and save.
Steps to reproduce
- Clear all caches.
- Open Site B in the frontend. Output is correct:
** Hello, from the site set!
** Hello, from the site TypoScript record.
** Hello, from the TypoScript include.
- Clear all caches again.
- Trigger TypoScript evaluation in the backend for Site B: open Site B (with the Form content element) in the “Layout” (Page) backend module.
- Open Site B in the frontend. Output is now:
** Hello, from the site set!
** Hello, from the site TypoScript record.
** (Missing) Hello, from the TypoScript include.
- The backend evaluation (global rootline) primes sys-template-setup-<hash>.php without the shared include, and the frontend reuses it with its local rootline, so the include is skipped.</hash>
Actual result
- Frontend TypoScript for Site B no longer contains the shared include when a backend evaluation primed the cache first. Behaviour changes depending on where TypoScript is first evaluated after cache flush.
Expected result
- Frontend should always see all TypoScript templates configured in the local site rootline, regardless of backend evaluation order. Frontend and backend either need aligned rootline semantics or isolated caches so one context cannot invalidate the other.
Impact
- In multi-site setups with TypoScript roots, parts of TypoScript can randomly disappear in frontend after certain backend actions. Depending on how critical the shared include is, this can range from broken features to a full site outage. Configuration looks correct in templates, but effective TypoScript depends on cache state and evaluation order.
Technical notes
- Frontend scopes the rootline to the site TypoScript root: EXT:frontend/Classes/Page/PageInformationFactory.php (setLocalRootLine(), uses Site::isTypoScriptRoot() / PageInformationFactory::setLocalRootLine()).
- Backend evaluation builds the rootline from the global root without applying Site::isTypoScriptRoot(): EXT:extbase/Classes/Configuration/BackendConfigurationManager.php (getTypoScriptSetup() uses RootlineUtility and passes the full rootline to SysTemplateRepository->getSysTemplateRowsByRootline()).
- TypoScript template processing deduplicates basedOn includes per evaluation and persists the effective include chain in per-template cache files sys-template-setup-<hash>.php. Sharing this cache between frontend (local rootline) and backend (global rootline) causes the divergence.</hash>
Possible directions
- Make backend TypoScript evaluation respect Site::isTypoScriptRoot() (similar scoping to frontend).
- Separate frontend/backend TypoScript caches so different rootlines cannot affect each other.
- Adjust basedOn deduplication to include the evaluation root/context in the cache key or avoid stripping includes that are required when starting from a different rootline.