-
Christian Kuhn authored
The patch extracts TSFE->determineId() and its sub methods from TSFE into TypoScriptFrontendInitialization middleware. The information created by these methods is modeled into the new DTO PageInformation, which is added as 'frontend.page.information' request attribute before handling other middlewares below. The non-internal old properties within TSFE are set and kept as b/w compat layer for now. This is a powerful change: It allows us to reduce dependencies to TSFE significantly, which we will start to leverage with upcoming patches. The patch is an intermediate change as such: Looking at determineId() and its related methods makes clear the code can benefit heavily from further refactoring. The method could be ultimately extracted into a service class that only returns the 'final' PageInformation object, or throws exceptions for 'early' responses. To keep the patch reviewable at this point, these refactorings will continue with additional patches. Detail notes: * TSFE->sys_page PageRepository instance is for now modeled as (@internal) PageInformation->pageRepository. This can be refactored away later: Consumers should create instances of that class on demand. * "original mount and shortcut page record" are also modeled as (@internal) PageInformation properties for now. They are internal handling since the redirects can only be created after TypoScript has been calculated later on, so the information has to be carried around for now. We *may* be able to change this later. * The two middleware properties $pageNotFound and $pageAccessFailureHistory are a tribute to the current code flow in determineId(). They should be refactored away when the code is further shuffled around. The properties currently require a hack that needs to make the middleware "shared: false" to circumvent side effects in combination with error handling sub requests. * The code flow around determineId() updates local state and state of PageInformation multiple times and is in general very hard to follow. The patch crafted this carefully and did not refactor the code flow heavily for now. Changing the early response creation strategy will make the code flow much more straightforward later. * determineId() and with it the PageInformation object is now created *before* TSFE is instantiated, shifting the instantiation to a slightly later point. * getPageAccessFailureReasons() is for now transferred to the middleware as well. It can be later dissolved when determineId() receives further refactoring. Two consumers (indirectly) by ShortcutAndMountPointRedirect middleware could be dissolved already, so the method could be removed from TSFE. * TSFE->linkVars needs to be dissolved soon: The strategy should be to create "linkVars" on demand within the link handling code and eventually encapsulate it with a runtime cache entry. * getRedirectUriForMountPoint() and getRedirectUriForShortcut() are relocated to ShortcutAndMountPointRedirect middleware. TSFE->getUriToCurrentPageForRedirect() had to be made (@internal) public to do that, but that method can be refactored away when TSFE->linkVars is dissolved. * The hacks within RedirectService are extended to deal with the new situation for now. The entire thing needs to fall at a later point completely. * Further patches should start avoiding the TSFE properties that are now set as b/w compat layer, and start using the PageInformation request attribute instead. This will reduce overall dependencies to TSFE significantly. Resolves: #102715 Releases: main Change-Id: I6470899cf65cbaaeb2177a8b20c0800f045a070c Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82267 Reviewed-by:
Benni Mack <benni@typo3.org> Reviewed-by:
Stefan Bürk <stefan@buerk.tech> Tested-by:
Benni Mack <benni@typo3.org> Tested-by:
core-ci <typo3@b13.com> Tested-by:
Christian Kuhn <lolli@schwarzbu.ch> Tested-by:
Stefan Bürk <stefan@buerk.tech> Reviewed-by:
Christian Kuhn <lolli@schwarzbu.ch>
a4cef9b3