Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#39407 closed defect (bug) (fixed)

Twenty Fourteen fatals in WordPress < 4.0.0

Reported by: n247s's profile n247s Owned by: davidakennedy's profile davidakennedy
Milestone: 4.8 Priority: normal
Severity: normal Version: 4.5
Component: Bundled Theme Keywords: has-patch
Focuses: Cc:

Description

After updating theme "twentyfourteen" to the newest version (Stable tag: 1.9) I got an "internal Server error (code=500)", not only when accesing the site itself, but also when trying to acces the admin-tool.

I enable logging and found a single line printed in the logs:

[27-Dec-2016 15:31:05 UTC] PHP Fatal error:  Call to undefined function is_customize_preview() in /mnt/web016/d2/13/52084413/htdocs/WordPress_01/wp-content/themes/twentyfourteen/inc/widgets.php on line 40

I tried to manually update the Theme via FTP acces resulting in the same error.

I hope this is enough information, if you need more feel free to ask.

Attachments (1)

39407.diff (875 bytes) - added by adamsilverstein 8 years ago.

Download all attachments as: .zip

Change History (9)

#1 @adamsilverstein
8 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.8
  • Version changed from 3.8.1 to 4.5

@n247s Thanks for the bug report. What version of WordPress are you running?

The line of code throwing the error was introduced in WordPress 4.5 in [37040] "Customize: Require opt-in for selective refresh of widgets.". Since is_customize_preview() was introduced in 4.0.0 and Twenty Fourteen should work from WordPress 3.6 and up, this is a problem. Introducing a shim for this function directly in the theme is probably a safe fix.

Last edited 8 years ago by adamsilverstein (previous) (diff)

#2 @adamsilverstein
8 years ago

In 39407.diff:

Themes: In Twenty Fourteen, add an is_customize_preview function if it is missing.

#3 @adamsilverstein
8 years ago

  • Summary changed from Couldn't call method 'is_customize_preview()' in Widget.php to Twenty Fourteen fatals in WordPress < 4.0.0

#4 @SergeyBiryukov
8 years ago

  • Component changed from Themes to Bundled Theme
  • Keywords has-patch added; needs-patch removed

This ticket was mentioned in Slack in #core-themes by adamsilverstein. View the logs.


8 years ago

This ticket was mentioned in Slack in #core-themes by davidakennedy. View the logs.


8 years ago

#7 @davidakennedy
8 years ago

Thanks @n247s for the report! Great catch, and welcome to Trac.

Thanks @adamsilverstein for the debugging and patch. It works well, and as we discussed in Slack, this seems like the best and cleanest solution. In a perfect world, we wouldn't have rolled in these changes to Twenty Fourteen had it been caught in testing. But this seems like the best direction.

I tested on a few versions below 4.0 and the patch works as expected.

#8 @davidakennedy
8 years ago

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

In 40022:

Twenty Fourteen: Fix fatal errors in WordPress versions before 4.0.0

The line of code throwing the error was introduced in WordPress 4.5 in r37040 "Customize: Require opt-in for selective refresh of widgets". Since is_customize_preview() was introduced in 4.0.0 and Twenty Fourteen should work from WordPress 3.6 and up, this caused the issue.

The patch adds an is_customize_preview function if it's missing.

Props adamsilverstein.

Fixes #39407.

Note: See TracTickets for help on using tickets.