Commit f743bc5
committed
[BUGFIX] Restore Context and DI container state
FrameworkState::push()/pop() back up and restore framework state
around frontend sub-requests fired with executeFrontendSubRequest().
Two pieces of global state were not covered so far: the Context
singleton and the globally registered dependency injection
container.
executeFrontendSubRequest() boots the frontend application through
Bootstrap::init(), which registers a fresh container and fills the
Context with the aspects of the frontend request, most notably the
language aspect. As neither was restored afterwards, code running
after a sub-request within the test scope silently continued with
frontend request state, for instance Extbase repository calls
resolving records in the language of the sub-request instead of the
default language.
push() now clones the current Context and container, reset() applies
a pristine Context and drops the container, and pop() puts both back
in place. Context is a singleton whose instance reference is held in
many places, so its aspects are copied over using reflection instead
of exchanging the object itself.
The core change
https://review.typo3.org/c/Packages/TYPO3.CMS/+/94931 describes the
very same leak and works around it in the affected test case by
resetting the language aspect by hand. That part of the workaround
becomes obsolete with this patch.
The class is further hardened along the way: a State array shape is
declared and applied to the state stack payload, giving proper type
information for the pushed and popped values, and pop() now throws a
dedicated exception instead of running into undefined array access
when the stack is empty.
Releases: main1 parent 9724b52 commit f743bc5
1 file changed
Lines changed: 35 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
32 | 49 | | |
33 | 50 | | |
34 | 51 | | |
| |||
39 | 56 | | |
40 | 57 | | |
41 | 58 | | |
| 59 | + | |
42 | 60 | | |
43 | 61 | | |
44 | 62 | | |
| |||
61 | 79 | | |
62 | 80 | | |
63 | 81 | | |
| 82 | + | |
| 83 | + | |
64 | 84 | | |
65 | 85 | | |
66 | 86 | | |
| |||
73 | 93 | | |
74 | 94 | | |
75 | 95 | | |
| 96 | + | |
76 | 97 | | |
77 | 98 | | |
78 | | - | |
79 | 99 | | |
80 | 100 | | |
81 | 101 | | |
82 | 102 | | |
83 | 103 | | |
| 104 | + | |
| 105 | + | |
84 | 106 | | |
85 | 107 | | |
86 | 108 | | |
87 | 109 | | |
88 | 110 | | |
89 | 111 | | |
90 | 112 | | |
| 113 | + | |
91 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
92 | 118 | | |
93 | 119 | | |
94 | 120 | | |
| |||
109 | 135 | | |
110 | 136 | | |
111 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
112 | 146 | | |
113 | 147 | | |
0 commit comments