WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 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 2 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 nacin2 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.

comment:2 westi2 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.

comment:4 johnjamesjacoby2 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 2 years ago by johnjamesjacoby (previous) (diff)

johnjamesjacoby2 years ago

comment:5 nacin2 years ago

This might have been fixed in [20524].

comment:6 nacin2 years ago

  • Keywords close added

comment:7 johnjamesjacoby2 years ago

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

comment:8 nacin2 years ago

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

comment:9 nacin2 years ago

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