WordPress.org

Make WordPress Core

Opened 5 months ago

Closed 5 months ago

Last modified 3 months ago

#46811 closed defect (bug) (fixed)

White screen for admins on handled fatal errors

Reported by: axaak Owned by: flixos90
Milestone: 5.2 Priority: normal
Severity: normal Version: 5.2
Component: Site Health Keywords: needs-patch has-screenshots servehappy
Focuses: Cc:

Description

If a fatal error occurs (e.g. call to undefined function) whilst logged into the back-end as admin, admin user sees menu on the left but white screen on the right (see screenshot1.png).

Steps to recreate
WordPress 5.2-beta1-45112 running Twenty Nineteen theme.
Login to back-end as admin
Force call to undefined function error in plugin (line 54, hello.php version 1.7.2).
Click admin menu item, view screen.

Note:
Class class-wp-fatal-error-handler.php decides it will handle() this error. Line 41 checks to see if headers have already been sent (they have), if headers have been sent the error template is not displayed.
If this check is commented out then the message

The site is experiencing technical difficulties.

is shown in the back-end.
However, this does not help the admin user move forward and the new site check tool is not shown.

Attachments (2)

snapshot1.png (71.4 KB) - added by axaak 5 months ago.
White screen shown to admins
snapshot2.png (72.9 KB) - added by axaak 5 months ago.
technical difficulties message if you comment out headers sent check

Download all attachments as: .zip

Change History (11)

@axaak
5 months ago

White screen shown to admins

@axaak
5 months ago

technical difficulties message if you comment out headers sent check

#2 @flixos90
5 months ago

  • Milestone changed from Awaiting Review to 5.2

This ticket was mentioned in Slack in #core-php by schlessera. View the logs.


5 months ago

#4 @schlessera
5 months ago

During core-php office hours, we agreed we should keep printing the wp-error template when is_admin(), even if headers_sent().
Apparently, the wp_die pretty handler won’t reprint out the head stylings if the head was already opened in the admin, so it should be safe to do so.

#5 @joyously
5 months ago

Wasn't this affected by what is returned for the REST API? (getting HTML in the wrong context)

#6 @flixos90
5 months ago

  • Owner set to flixos90
  • Status changed from new to assigned

#7 @flixos90
5 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 45210:

General: Display fatal error handler notice in admin backend even if headers have been sent.

This ensures that at least for the admin, which is more predictable than the frontend, the user-friendlier error notice from the fatal error handler still shows if a runtime fatal error happens within the page generation process.

Props axaak.
Fixes #46811.

#8 @swissspidy
5 months ago

Wasn't this affected by what is returned for the REST API? (getting HTML in the wrong context)

is_admin() is not true for REST API requests, so that's unaffected here. is_admin() is true for admin-ajax.php request though.

#9 @spacedmonkey
3 months ago

  • Component changed from General to Site Health
Note: See TracTickets for help on using tickets.