Opened 14 months ago
Closed 13 months ago
#20334 closed defect (bug) (fixed)
check_theme_switched() will Fatal Error if the old theme cannot be found for some reason
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.4 |
| Component: | Themes | Version: | 3.4 |
| Severity: | normal | Keywords: | close |
| 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)
Change History (10)
- Resolution set to fixed
- Status changed from new to closed
In [20330]:
- 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.
johnjamesjacoby — 13 months ago
Confirmed fixed. The steps above no longer produce any errors.
Leaving this open to investigate a possible bug in the check_theme_switched() implementation.

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.