WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#20334 closed defect (bug) (fixed)

check_theme_switched() will Fatal Error if the old theme cannot be found for some reason

Reported by: westi Owned by: westi
Milestone: 3.4 Priority: normal
Severity: normal Version: 3.4
Component: Themes Keywords: close
Focuses: Cc:

Description

In check_theme_switched() we assume that we can get a WP_Theme object for the old theme.

If this fails because the theme no longer exists or the option data doesn't match an available theme then we try and call a method on an object which doesn't exist.

Attachments (1)

20334.patch (780 bytes) - added by johnjamesjacoby 10 years ago.

Download all attachments as: .zip

Change History (10)

#1 @nacin
10 years ago

As I said to westi in IRC, the theme_switched option is only supposed to exist until the next pageload. So if it still exists, then you have bigger problems. I'm definitely fine with checking the return value of wp_get_theme() and using the raw $stylesheet if necessary.

#2 @westi
10 years ago

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

In [20330]:

Avoid fatal errors in check_theme_switched() if we fail to get a WP_Theme object for the old theme. Fixes #20334.

#4 @johnjamesjacoby
10 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

This is still not completely fixed. Easiest way to duplicate is by renaming a theme in it's style.css when you're already at wp-admin/themes.php.

  • Visit wp-admin/themes.php
  • Rename any theme in style.css
  • Refresh wp-admin/themes.php
  • Fatal error: Call to a member function exists() on a non-object in /wp.local/wp/wp-includes/theme.php on line 1557
  • Error points to check_theme_switched()

Patch below circumvents the problem without digging too deep into the API.

Last edited 10 years ago by johnjamesjacoby (previous) (diff)

#5 @nacin
10 years ago

This might have been fixed in [20524].

#6 @nacin
10 years ago

  • Keywords close added

#7 @johnjamesjacoby
10 years ago

Confirmed fixed. The steps above no longer produce any errors.

#8 @nacin
10 years ago

Leaving this open to investigate a possible bug in the check_theme_switched() implementation.

#9 @nacin
10 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.