78720[BUGFIX] Restore correct context after redirect evaluation
Commit message
Review
-
Code review CR +2 Done
- Stefan Bürk +2
- Christian Kuhn +1
-
Verified V +2 Done
- Stefan Bürk +2
- Christian Kuhn +1
- core-ci +1 CI
Issues 1
Files 2
Review log 1517
-
Markus Klein uploaded patch set 1 04/18/23, 08:38
-
core-ci voted on patch set 1 V +1 04/18/23, 08:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40853
-
Johannes Kasberger voted on patch set 1 V +1 CR +1 04/18/23, 13:48
-
Christian Kuhn commented on patch set 1 04/19/23, 10:23
I'd be fine with this hack for now, when he Context method is declared @internal. However, let me at least state the "true" solution: The redirects middleware should initiate a sub request instead! This will avoid the ugly early created tsfe instance along the way. The created request should then have some attribute declaring it is a sub request of the redirect logic (maybe containing a counter, or a list of urls), the middleware should then check this attribute to prevent recursion loops. We could add some @todo at an appropriate place in the middleware or service stating this should be refactored towards sub requests.Context.php:158existance of this method is a sign for a technical debt. if we need this as bug fix, we should at least mark this "@internal May vanish any time". I'd be fine with this hack for now, when something like this is added. See my comment on the "true" solution, too. -
Christian Kuhn voted on patch set 1 CR -1 04/19/23, 10:23
-
Markus Klein commented on patch set 1 04/19/23, 10:44
Context.php:158ReplyI'm fully with you that this is only quick solution to mitigate this issue. Despite a subrequest would be deferred, I still think that this semi-immutable singleton Context class is a very unfortunate construct. It actually a global "variable", which can cope with missing aspects, but once an aspect is set, it can never be removed. This has a smell to me. -
Christian Kuhn commented on patch set 1 04/19/23, 11:55
Context.php:158ReplyI don't think the Context singleton is a smell as such: It's scope is to be set up during bootstrap and enriched during middlewares. Code below (controllers, other levels below) should never change it afterwards. Middlewares that need to remove context aspects are located at a wrong place in the chain or have different technical debt, just like the redirect handling. Sub requests always go through the middleware chain a-new, and a new context will be created for the sub request. Before initiating a sub request, list of current singletons needs to be fetched, set to empty, and should be reset afterwards. This takes care of all state since we removed all static state properties meanwhile. The testing-framework does this for instance, and i guess we'll have a helper for this in the core later, as well. Note the "long living" globals TCA and TYPO3_CONF_VARS are not affected by this, since they must not change in-between requests anyways. All other globals that currently need to be backed up before sub requests (BE_USER, LANG, ...) are target for short to mid-term removal. So: The only state we need to take care of in sub requests are singletons in the end, at least for quite a while. I think that's an ok'ish thing. And context is just one of them. It should not need to have an unset() method. -
Georg Ringer voted on patch set 1 CR +1 04/19/23, 20:55
-
Christian Kuhn uploaded patch set 2
CR +1V +104/21/23, 13:02 -
Christian Kuhn commented on patch set 1 CR -1 04/21/23, 13:02
Context.php:158ReplyDone -
core-ci voted on patch set 2 V +1 04/21/23, 13:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41035
-
Christian Kuhn voted on patch set 2 V +1 CR +1 04/21/23, 13:19
-
Christian Kuhn commented on patch set 2 04/21/23, 13:21
pinged benni on this. hope he states some vote as well. -
Christian Kuhn commented on patch set 2 04/21/23, 16:30
got "looks ok" from benni. -
Stefan Bürk voted on patch set 2 V +1 CR +1 04/21/23, 16:36
-
Stefan Bürk voted on patch set 2 V +2 CR +2 04/21/23, 16:36
-
Stefan Bürk merged patch set 3 04/21/23, 16:36