Breaking: #97816 - New TypoScript parser in Frontend

See forge#97816

Description

The rewrite of the TypoScript parser has been enabled for Frontend rendering.

See Breaking: #97816 - TypoScript syntax changes and Feature: #97816 - TypoScript syntax improvements for more details on the new parser.

Impact

The change has impact on Frontend caching, hooks, some classes and properties. In detail:

  • Hook $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Core/TypoScript/TemplateService']['runThroughTemplatesPostProcessing'] is gone and substituted by AfterTemplatesHaveBeenDeterminedEvent. See Feature: #97816 - New AfterTemplatesHaveBeenDeterminedEvent for more details.

  • The classes TYPO3\CMS\Core\TypoScript\TemplateService and TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser have been marked as deprecated and shouldn't be used anymore. An instance of TemplateService is still kept as property TypoScriptFrontendController->tmpl ($GLOBALS['TSFE']->tmpl) as backwards compatible layer, and the most important properties within the class, namely especially :php:`TemplateService->setup is still set. To avoid using these properties, the Frontend request object will contain this state. In rare cases, where extensions need to parse TypoScript on their own, they should switch to the Tokenizer and AstBuilder structures of the new parser. Note these classes are still young and currently marked @internal, the API may still slightly change with further v12 development.

  • The pagesection cache has been removed. This was a helper cache that grew O(n) with the number of called Frontend pages. The new typoscript cache is used instead: This grows only O(n) with the number of different sys_template and condition combinations and is a filesystem based PhpFrontend implementation. When upgrading, the database tables cache_pagesection and cache_pagesections_tags can be safely removed, the install tool will also silently remove any existing entries from settings.php that reconfigure the cache.

  • The Frontend rendering changed TypoScript cache behavior slightly, which may have an impact on integrators developing and testing TypoScript in the Frontend. The short version is: When changing sys_template records, changes have immediate effect, and when changing included TypoScript files, the Frontend browser tab should be reloaded using "shift-reload" or the browser inspector should be opened and the "Disable cache" toggle turned on. Note when changes like this should go live for everyone, Frontend caches must still be cleared using the Backend toolbar "Flush frontend caches" to have an effect on "normal users" without active Backend login.

    Some more details on this: Frontend TypoScript in general now uses caches across multiple pages, which increases rendering performance. After calling a first page with empty caches, a second page call to a different page will re-use most, if not all, TypoScript from cache entries created by the first page access.

    This has impact on cache invalidation when developing Frontend TypoScript: First, changing sys_template records always has immediate effect to all requests, even without clearing caches manually. The system detects field changes of sys_template changes automatically, reloading a page in the Frontend will trigger re-calculation of TypoScript and thus re-rendering of the page. Note this is only true for directly loaded sys_template records. Changes on records included indirectly via the relatively seldom used basedOn field are not detected automatically, and the same systematics as outlined below for file includes kicks in.

    The cache behavior is slightly different for files included using @import, <INCLUDE_TYPOSCRIPT: ... and for sys_template records included using the basedOn field. To suppress expensive filesystem calls in production, the cache layer for included files is more aggressive and does not automatically trigger Frontend page re-rendering when included TypoScript files are changed. There are however some ways to easily work around this as an integrator: When a backend user is logged in, a Frontend call recognizes this since various functionality is bound to logged in Backend users in the Frontend, most notably the ability to preview hidden pages or hidden content, and the admin panel functionality. When changing Frontend TypoScript in included files, being logged in with a Backend user, and then pressing "shift-reload" for the Frontend page, this will trigger "no cache", which forces content re-rendering including TypoScript re-calculation. Additionally, the "Browser Inspectors" in Chrome and Firefox both have a "Disable cache" toggle, which sends the same HTTP header as done with "shift-reload", which will also force re-rendering. Note integrators should still "Flush frontend caches" when changes in included TypoScript files should go-live for all other Frontend requests and thus "normal users" as well.

  • The following properties and methods in TypoScriptFrontendController have been set to @internal and should not be used any longer since they may vanish without further notice:

    • TypoScriptFrontendController->no_cache

    • TypoScriptFrontendController->tmpl

    • TypoScriptFrontendController->pageContentWasLoadedFromCache

    • TypoScriptFrontendController->getFromCache_queryRow()

    • TypoScriptFrontendController->populatePageDataFromCache()

    • TypoScriptFrontendController->shouldAcquireCacheData()

    • TypoScriptFrontendController->acquireLock()

    • TypoScriptFrontendController->releaseLock()

  • The following methods in TypoScriptFrontendController have been removed:

    • TypoScriptFrontendController->getHash()

    • TypoScriptFrontendController->getLockHash()

    • TypoScriptFrontendController->getConfigArray()

    • TypoScriptFrontendController->()

Affected installations

Many instances will only recognize that the pagesection cache is gone and should continue to work. Instances with extensions that use TemplateService or TypoScriptParser, or access the property TypoScriptFrontendController->tmpl may need adaptions.

Migration

See the impact description above for some migration hints.