[TASK] Do not use ConfigurationManager in FormPersistenceManager
The FormPersistenceManager is a central class of ext:form that takes care of .form.yaml writing and loading. This includes overloading with form specific TypoScript settings and sanitation of storage locations based on module.tx_form TypoScript. Since ext:form is designed as an extbase extension, FormPersistenceManager relies on extbase ConfigurationManager to retrieve TypoScript. The ext:form internal own variant of extbase ConfigurationManager has this dependency as well. This wouldn't be a huge problem if FormPersistenceManager is only used from within the extbase bootstrapped extension context only. FormPersistenceManager however is used 'out-of-context' in three places: It is used within the BE FormEngine related flex form data structure handling hook, within the BE page module related content element preview rendering, and by the formvh:render view helper. These three places do not have an extbase context, so extbase, and especially the extbase related stateful injectable singleton ConfigurationManager, has not been configured at these points. Extbase ConfigurationManager, and in turn the ext:form extended variant as well, have a dependency to the request to work properly and thus rely on the request being set up correctly. To deal with this, FormPersistenceManager configures extbase ConfigurationManager within __construct() by handing over the request from $GLOBALS['TYPO3_REQUEST']. This is bad for a series of reasons, one being obviously the access to $GLOBALS['TYPO3_REQUEST'] within __construct() in the first place. Also, FormPersistenceManager is quite often used *within* properly configured extbase context as well, for instance from within the extbase based ext:form controllers, so FormPersistenceManager then reconfigures extbase ConfigurationManager with the (non-extbase) global request and thus messes up its state. The problem is here that FormPersistenceManager does not and can not know wether its used 'out-of-context'. To deal with this, the patch removes use of ConfigurationManager to retrieve TypoScript within FormPersistenceManager, and forces consumers to hand it over to those methods that need it. The idea is that only the callers know their context and can take care of setting up ConfigurationManager as needed on their own. This approach makes the dependency to the request object explicit: Two of the three 'out-of-context' places are "ok" with that: The BE page module preview rendering has the request available, the formvh:render view helper as well. The third one will be harder to resolve: The flex form related data structure handling has not been designed to have the request, there may or may not be CLI situations in this low level handling where no request is available. This needs further analysis, the patch outlines various options for now. The patch forces FormPersistenceManagerInterface to be adapted, which should not be a huge issue since the overall functionality is ext:form internal, and there shouldn't be extensions that use it directly. The patch is thus *not* considered breaking and FormPersistenceManagerInterface is now declared @internal along the way to reflect this. Also, as usual when working in this area, the related tests receive an overhaul to deal with the new signatures and internal handling, and to be more easy to maintain. Also, class ext:form ConfigurationService suffers from similar issues as outlined above and will probably need a revamp as well. This one however is only used in combination with FormPersistenceManager when used 'out-of-context', so the changes for FormPersistenceManager relax this situation as well. Still, and @todo is left in it. Resolves: #104667 Related: #92408 Related: #102558 Releases: main Change-Id: I555aa6445f1fad577253cf90065df540a5830bd7 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85669 Reviewed-by:Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by:
Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by:
Stefan Bürk <stefan@buerk.tech> Tested-by:
core-ci <typo3@b13.com> Tested-by:
Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by:
Stefan Bürk <stefan@buerk.tech> Tested-by:
Christian Kuhn <lolli@schwarzbu.ch>
Showing
- typo3/sysext/core/Classes/Domain/Repository/PageRepository.php 9 additions, 0 deletions.../sysext/core/Classes/Domain/Repository/PageRepository.php
- typo3/sysext/form/Classes/Controller/FormEditorController.php 7 additions, 5 deletions...3/sysext/form/Classes/Controller/FormEditorController.php
- typo3/sysext/form/Classes/Controller/FormFrontendController.php 6 additions, 1 deletion...sysext/form/Classes/Controller/FormFrontendController.php
- typo3/sysext/form/Classes/Controller/FormManagerController.php 27 additions, 26 deletions.../sysext/form/Classes/Controller/FormManagerController.php
- typo3/sysext/form/Classes/Domain/Configuration/ConfigurationService.php 6 additions, 1 deletion...orm/Classes/Domain/Configuration/ConfigurationService.php
- typo3/sysext/form/Classes/EventListener/DataStructureIdentifierListener.php 93 additions, 114 deletions...Classes/EventListener/DataStructureIdentifierListener.php
- typo3/sysext/form/Classes/Hooks/FormPagePreviewRenderer.php 42 additions, 34 deletionstypo3/sysext/form/Classes/Hooks/FormPagePreviewRenderer.php
- typo3/sysext/form/Classes/Mvc/Configuration/TypoScriptService.php 5 additions, 11 deletions...sext/form/Classes/Mvc/Configuration/TypoScriptService.php
- typo3/sysext/form/Classes/Mvc/Persistence/FormPersistenceManager.php 170 additions, 297 deletions...t/form/Classes/Mvc/Persistence/FormPersistenceManager.php
- typo3/sysext/form/Classes/Mvc/Persistence/FormPersistenceManagerInterface.php 22 additions, 17 deletions...asses/Mvc/Persistence/FormPersistenceManagerInterface.php
- typo3/sysext/form/Classes/ViewHelpers/RenderViewHelper.php 22 additions, 15 deletionstypo3/sysext/form/Classes/ViewHelpers/RenderViewHelper.php
- typo3/sysext/form/Configuration/Services.yaml 0 additions, 4 deletionstypo3/sysext/form/Configuration/Services.yaml
- typo3/sysext/form/Documentation/I/Concepts/FrontendRendering/Index.rst 3 additions, 3 deletions...form/Documentation/I/Concepts/FrontendRendering/Index.rst
- typo3/sysext/form/Tests/Functional/Controller/FormFrontendControllerTest.php 4 additions, 20 deletions...ests/Functional/Controller/FormFrontendControllerTest.php
- typo3/sysext/form/Tests/Functional/Controller/FormManagerControllerTest.php 2 additions, 2 deletions...Tests/Functional/Controller/FormManagerControllerTest.php
- typo3/sysext/form/Tests/Functional/EventListener/DataStructureIdentifierListenerTest.php 100 additions, 76 deletions...nal/EventListener/DataStructureIdentifierListenerTest.php
- typo3/sysext/form/Tests/Functional/Mvc/Persistence/Fixtures/BlankForm.form.yaml 0 additions, 0 deletions...s/Functional/Mvc/Persistence/Fixtures/BlankForm.form.yaml
- typo3/sysext/form/Tests/Functional/Mvc/Persistence/Fixtures/BlankForm.txt 0 additions, 0 deletions...m/Tests/Functional/Mvc/Persistence/Fixtures/BlankForm.txt
- typo3/sysext/form/Tests/Functional/Mvc/Persistence/Fixtures/Simple.form.yaml 13 additions, 0 deletions...ests/Functional/Mvc/Persistence/Fixtures/Simple.form.yaml
- typo3/sysext/form/Tests/Functional/Mvc/Persistence/FormPersistenceManagerTest.php 1034 additions, 0 deletions...Functional/Mvc/Persistence/FormPersistenceManagerTest.php
Please register or sign in to comment