TYPO3-Documentation / Changelog-To-Doc

1 stars 0 forks source link

[!!!][TASK] Use new TypoScript parser in Frontend #215

Closed TYPO3IncTeam closed 1 year ago

TYPO3IncTeam commented 1 year ago

:information_source: View this commit on Github :busts_in_silhouette: Authored by Christian Kuhn lolli@schwarzbu.ch :heavy_check_mark: Merged by Benni Mack benni@typo3.org

Commit message

[!!!][TASK] Use new TypoScript parser in Frontend

This switches from TemplateService to new TypoScript parser logic in TypoScriptFrontendController.

The central methods getFromcache() and getConfigArray() were called in PrepareTypoScriptFrontendRendering after each other: getConfigArray() is now merged into getFromcache() directly.

One main goal is to get rid of the 'pagesection' cache and leverage the new cache strategy of the new TypoScript parser: This cache strategy is more effective and allows caching TypoScript between different pages.

We essentially get rid of the pagesection query load, but instead need the list of relevant sys_template rows early, which is done with a single query. This code is moved out of IncludeTree/TreeBuilder to new class IncludeTree/SysTemplateRepository, since the result is now needed to build page cache identifiers and thus must be exposed.

An event is added as well, for extensions like ext:bolt to manipulate sys_template rows resolving. The old runThroughTemplatesPostProcessing hook is marked @internal now and will vanish during further v12 development when testing-framework has been changed to deal with it.

The central getFromcache() is much better documented and should be far easier to understand now. Some parts of the code are currently a bit naive and there is quite a bit potential to further optimize parsetime especially in "full cached" scenarios. We also have the potential to make USER_INT parsing significantly quicker. Dedicated patches will follow with continued v12 development.

The patch also sets a couple of properties to @internal, and marks the old TypoScriptParser and TemplateService @deprecated, even though it is currently still used for instance for TSconfig parsing, which will switch to the new parser soon as well.

Resolves: #98503 Related: #97816 Releases: main Change-Id: I904e9add4a425479df4a6768a1d63a54d7b252d8 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75944 Tested-by: Stefan Bürk stefan@buerk.tech Tested-by: core-ci typo3@b13.com Tested-by: Benni Mack benni@typo3.org Reviewed-by: Stefan Bürk stefan@buerk.tech Reviewed-by: Benni Mack benni@typo3.org

:heavy_plus_sign: Added files

12.0/Breaking-97816-NewTypoScriptParserInFrontend.rst ```rst .. include:: /Includes.rst.txt .. _breaking-97816-1664800747: ==================================================== Breaking: #97816 - New TypoScript parser in Frontend ==================================================== See :issue:`97816` Description =========== The rewrite of the TypoScript parser has been enabled for Frontend rendering. See :ref:`breaking-97816-1656350406` and :ref:`feature-97816-1656350667` for more details on the new parser. Impact ====== The change has impact on Frontend caching, hooks, some classes and properties. In detail: * Hook :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Core/TypoScript/TemplateService']['runThroughTemplatesPostProcessing']` is gone and substituted by :php:`AfterTemplatesHaveBeenDeterminedEvent`. See :ref:`feature-97816-1664801053` for more details. * The classes :php:`TYPO3\CMS\Core\TypoScript\TemplateService` and :php:`TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser` have been marked as deprecated and shouldn't be used anymore. An instance of :php:`TemplateService` is still kept as property :php:`TypoScriptFrontendController->tmpl` (:php:`$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 :php:`pagesection` cache has been removed. This was a helper cache that grew O(n) with the number of called Frontend pages. The new :php:`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 :php:`PhpFrontend` implementation. When upgrading, the database tables :sql:`cache_pagesection` and :sql:`cache_pagesections_tags` can be safely removed, the install tool will also silently remove any existing entries from :file:`settings.php` that reconfigure the cache. * The following properties and methods in :php:`TypoScriptFrontendController` have been set to :php:`@internal` and should not be used any longer since they may vanish without further notice: * :php:`TypoScriptFrontendController->no_cache` * :php:`TypoScriptFrontendController->tmpl` * :php:`TypoScriptFrontendController->pageContentWasLoadedFromCache` * :php:`TypoScriptFrontendController->getFromCache_queryRow()` * :php:`TypoScriptFrontendController->populatePageDataFromCache()` * :php:`TypoScriptFrontendController->shouldAcquireCacheData()` * :php:`TypoScriptFrontendController->acquireLock()` * :php:`TypoScriptFrontendController->releaseLock()` * The following methods in :php:`TypoScriptFrontendController` have been removed: * :php:`TypoScriptFrontendController->getHash()` * :php:`TypoScriptFrontendController->getLockHash()` * :php:`TypoScriptFrontendController->getConfigArray()` * :php:`TypoScriptFrontendController->()` Affected installations ====================== Many instances will only recognize that the :php:`pagesection` cache is gone and should continue to work. Instances with extensions that use :php:`TemplateService` or :php:`TypoScriptParser`, or access the property :php:`TypoScriptFrontendController->tmpl` may need adaptions. Migration ========= See the impact description above for some migration hints. .. index:: Database, Frontend, PHP-API, TypoScript, LocalConfiguration, PartiallyScanned, ext:frontend ```
12.0/Feature-97816-NewAfterTemplatesHaveBeenDeterminedEvent.rst ```rst .. include:: /Includes.rst.txt .. _feature-97816-1664801053: =========================================================== Feature: #97816 - New AfterTemplatesHaveBeenDeterminedEvent =========================================================== See :issue:`97816` Description =========== With switching to the new TypoScript parser, hook :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Core/TypoScript/TemplateService']['runThroughTemplatesPostProcessing']` has been removed. The new event :php:`AfterTemplatesHaveBeenDeterminedEvent` can be used to manipulate sys_template rows. The event receives the list of resolved sys_template rows and the :php:`SiteInterface` and allows manipulating the sys_template rows array. Impact ====== The event is called in Backend EXT:tstemplate code, for example in the Template Analyzer, and - more importantly - in the Frontend. Extensions using the old hook that want to stay compatible with both core v11 and v12 can implement both. .. index:: PHP-API, TypoScript, ext:core ```
linawolf commented 1 year ago

@lolli42 will document this himself

linawolf commented 1 year ago

This is solved