Opened 8 months ago

Last modified 8 months ago

#21931 reopened enhancement

White screen of death if theme can't be found

Reported by: ericlewis Owned by:
Priority: normal Milestone: Awaiting Review
Component: Themes Version:
Severity: normal Keywords: 2nd-opinion dev-feedback
Cc: mdhansen@…

Description

If the current theme can't be found or is renamed, the front-end of the site will white screen. This is developer error, as when WP_USE_THEMES is true, the template loader should always have a template to load (as far as I understand).

It's rare, but I come across it every once in a while in developing. It might be nice to have a wp_die() if a proper template can't be found in template-loader.

Proof of concept:

if ( $template = apply_filters( 'template_include', $template ) )
	include( $template );
else
	wp_die("Whoops! Looks like you're missing a theme.");

Attachments (2)

21931.diff (537 bytes) - added by MikeHansenMe 8 months ago.
21931.2.diff (497 bytes) - added by SergeyBiryukov 8 months ago.

Download all attachments as: .zip

Change History (18)

I think this is a good idea as most users would not know where to begin looking if they experienced a white screen.

Last edited 8 months ago by MikeHansenMe (previous) (diff)
  • Cc mdhansen@… added
Last edited 8 months ago by miqrogroove (previous) (diff)
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #11282.

  • Resolution duplicate deleted
  • Status changed from closed to reopened

Related, but not exactly a duplicate.

comment:6 follow-up: ↓ 7   scribu8 months ago

I've also run into this. Should be careful with the error message, since it can show up on live sites in certain circumstances.

comment:7 in reply to: ↑ 6   ericlewis8 months ago

Replying to scribu:

Should be careful with the error message, since it can show up on live sites in certain circumstances.

Can you expand on that? I can't imagine the circumstance where $template is expected to be empty.

comment:8 follow-up: ↓ 14   scribu8 months ago

I remember I screwed up a deploy once and the theme was renamed. Since I had deleted the twentyeleven theme, I got a WSOD. With this bug, I would get a message instead.

What I'm saying is that the error message shouldn't assume that it will only be seen by developers.

comment:9 follow-up: ↓ 10   MikeHansenMe8 months ago

what about "Looks like the website is having theme trouble, please notify the site owner" or something to that effect?

comment:10 in reply to: ↑ 9   ericlewis8 months ago

After chatting with Nacin in IRC a bit, some thought has to be put in here in regard to the ambiguity of the problem, and the ambiguity of the audience. This situation may arise from not just the themes folder missing, it may be a filesystem error, or come from another unknown cause. Therefore, our presentation of the error should respect this fact, and not send developers with possibly misleading debug information.

Last edited 8 months ago by ericlewis (previous) (diff)

It's nearly the same thing, but not quite; as the developer, you can at least know that WP was loaded.

And if there's a hook available, you can write a plugin that outputs a more useful message or logs it somewhere.

Could we do something along the lines of what wp_dashboard_right_now() does?
http://core.trac.wordpress.org/browser/tags/3.4.2/wp-admin/includes/dashboard.php#L365

If the current theme is not found, 21931.2.diff shows "The theme directory does not exist".

Related: #21670 (for more exact message in the admin).

Last edited 8 months ago by SergeyBiryukov (previous) (diff)

comment:13 follow-up: ↓ 15   MikeHansenMe8 months ago

The thing about using Right Now in the dashboard to deliver messages is that it can be turned off. Perhaps there is a problem with that as well. Either not allow right now to be turned off or move error messages above the separate content blocks?

comment:14 in reply to: ↑ 8   johnbillion8 months ago

Replying to scribu:

What I'm saying is that the error message shouldn't assume that it will only be seen by developers.

Let's make the message capability-dependant then.

if ( current_user_can( 'switch_themes' ) )
	$message = __( 'You just broke everything!' );
else
	$message = __( 'Everything is fine and we will be back shortly.' );

wp_die( $message );

comment:15 in reply to: ↑ 13 ; follow-up: ↓ 16   SergeyBiryukov8 months ago

Replying to MikeHansenMe:

The thing about using Right Now in the dashboard to deliver messages is that it can be turned off.

The idea behind 21931.2.diff was to display a similar message on the front end.

comment:16 in reply to: ↑ 15   MikeHansenMe8 months ago

Replying to SergeyBiryukov:

Replying to MikeHansenMe:

The thing about using Right Now in the dashboard to deliver messages is that it can be turned off.

The idea behind 21931.2.diff was to display a similar message on the front end.

I thought you were suggesting a user message in the front and developer error in the admin. I do think giving the error on the front end is a good idea because like I said, the Right Now area in the admin can be turned off. I think that may be a problem of it's own though.

Note: See TracTickets for help on using tickets.