File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -164,16 +164,20 @@ protected static function supportsHTML(HTTPRequest $request = null)
164
164
if (Director::is_cli ()) {
165
165
return false ;
166
166
}
167
+ $ accepted = [];
167
168
168
169
// Get current request if registered
169
170
if (!$ request && Injector::inst ()->has (HTTPRequest::class)) {
170
171
$ request = Injector::inst ()->get (HTTPRequest::class);
171
172
}
172
- if (!$ request ) {
173
- return false ;
173
+ if ($ request ) {
174
+ $ accepted = $ request ->getAcceptMimetypes (false );
175
+ } elseif (isset ($ _SERVER ['HTTP_ACCEPT ' ])) {
176
+ // If there's no request object available, fallback to global $_SERVER
177
+ // This can happen in some circumstances when a PHP error is triggered
178
+ // during a regular HTTP request
179
+ $ accepted = preg_split ('#\s*,\s*# ' , $ _SERVER ['HTTP_ACCEPT ' ]);
174
180
}
175
- // Request must include text/html
176
- $ accepted = $ request ->getAcceptMimetypes (false );
177
181
178
182
// Explicit opt in
179
183
if (in_array ('text/html ' , $ accepted ?? [])) {
You can’t perform that action at this time.
0 commit comments