Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#24441 closed defect (bug) (fixed)

Twenty Thirteen switch theme back compat missing argument

Reported by: offereins's profile Offereins Owned by: lancewillett's profile lancewillett
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.3
Component: Bundled Theme Keywords:
Focuses: Cc:

Description

Try activating Twenty Thirteen on a pre-3.4 install. It returns (on 3.3.2) a missing argument 2 for twentythirteen_switch_theme() error, because the pre-3.4 after_switch_theme action uses only 1 param ($old_theme).

I know, i'm not using the latest install of WP, but since inc/back-compat.php is breaking WP while the file header states explicitly: Prevents Twenty Thirteen from running on WordPress versions prior to 3.6, i'm guessing we need a fix.

Attachments (4)

24441.patch (1.3 KB) - added by obenland 12 years ago.
24441.wp_die_back.patch (935 bytes) - added by obenland 12 years ago.
Switch to the built in method of providing a back link in wp_die().
24441.2.patch (1.9 KB) - added by lancewillett 12 years ago.
24441.3.patch (2.4 KB) - added by lancewillett 12 years ago.
Adds 3.3 and earlier theme preview check and wp_die()

Download all attachments as: .zip

Change History (15)

#1 @lancewillett
12 years ago

Hmm. I think we agreed on going back to 3.4 (two major versions).

#2 follow-up: @nacin
12 years ago

  • Milestone changed from Awaiting Review to 3.6

This is in the back compat code that deactivates itself < 3.6, so I don't think it is too much to make sure it works pre-3.4.

It could do twentythirteen_switch_theme( $theme_name, $theme = null ) and then just switch to WP_DEFAULT_THEME if $theme is null. But I don't think twentythirteen_switch_theme() actually needs to check $theme at all. It can probably just switch_theme() to WP_DEFAULT_THEME. It's trying to be too clever — when would this code ever run when twentythirteen isn't the active theme?

#3 @nacin
12 years ago

A note, switch_theme() must be called with two arguments — switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME ) — to be compatible with pre-3.4.

It won't work if WP_DEFAULT_THEME is a child theme, but core *should* pick up on that, declare the default child theme to be broken, and finally revert to the real default theme. At worst, the front of the site is a white screen (and the admin works fine), but that's better than a fatal error.

@obenland
12 years ago

@obenland
12 years ago

Switch to the built in method of providing a back link in wp_die().

#4 in reply to: ↑ 2 ; follow-up: @obenland
12 years ago

Replying to nacin:

It's trying to be too clever — when would this code ever run when twentythirteen isn't the active theme?

Agreed, let's simplify.


Replying to nacin:

It won't work if WP_DEFAULT_THEME is a child theme, but core *should* pick up on that, declare the default child theme to be broken, and finally revert to the real default theme. At worst, the front of the site is a white screen (and the admin works fine), but that's better than a fatal error.

Do you mean if it's a child theme of Twenty Thirteen?

In my (short) tests the child theme (Hum => Twenty Eleven) worked just fine, I did not test it with a Twenty Thirteen child. When defining a non-existing theme, the front of the site is indeed white but the admin still works.

#5 in reply to: ↑ 4 @nacin
12 years ago

Replying to obenland:

Do you mean if it's a child theme of Twenty Thirteen?

Nope. The check if ( 'twentythirteen' != $theme->get_template() ) would imply that Twenty Thirteen could also be a child theme, given that this code is only run when Twenty Thirteen is activated.

#6 @lancewillett
12 years ago

Patches look good and test out in 3.3, 3.4, and 3.5.

For 3.3 and earlier, we could also handle the Preview functionality -- with this current patch it does not die or exit.

#7 @lancewillett
12 years ago

.2 combines both of the earlier patches from obenland.

@lancewillett
12 years ago

Adds 3.3 and earlier theme preview check and wp_die()

#8 @lancewillett
12 years ago

After discussing with Obenland and Nacin in #wordpress-dev today, I'd like to take a closer look at this.

Can we remove this compat file completely? After the post format functionality removal, Twenty Thirteen should be pretty close to error-free in older installs now.

#9 @obenland
12 years ago

In 3.4, Link and Gallery posts fatal with undefined functions and we'd need to style the old searchform and comments output.

#10 @lancewillett
12 years ago

In today's core dev chat, we discussed back compat. We're going to keep Twenty Thirteen 3.6+ only. By having the back compat file here, we avoid fatal errors in older versions. IRC log.

Last step here is to commit the 3.3 and earlier preview fix.

#11 @lancewillett
12 years ago

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

In 24411:

Twenty Thirteen: improve backward compatibility escape hatch for pre-3.6 versions:

  • Switch to the built-in method of providing a back link in wp_die() for the Customizer
  • Use WP_DEFAULT_THEME for both arguments during theme switching to simplify the logic
  • Prevent the 3.3 and earlier theme preview action gracefully

Props obenland for patches, fixes #24441.

Note: See TracTickets for help on using tickets.