Make WordPress Core

Opened 9 years ago

Closed 7 years ago

#31582 closed defect (bug) (fixed)

Catching PHP Fatal Errors on WordPress Theme Customizer

Reported by: nightcoder's profile nightcoder Owned by: westonruter's profile westonruter
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.1.1
Component: Customize Keywords: needs-patch
Focuses: Cc:

Description (last modified by westonruter)

I am developing a WordPress theme and added my a couple of new settings to the theme customizer panel. I don't have any custom JS code to share with you because i only added some new fields like shown at (

The Problem

I am getting this issue when i click the save and publish button of the customizer panel and the error comes with an ajax response. WordPress customizer keeps working and refreshes the right frame as if data saved successfully. When you see the right frame refreshed, you think it is safe to close the customizer window and loose the unsaved data. Many themes has expensive operations such as creating dynamic css outputs only for custumizer so the fatal error may not be effect any other admin or front end part.

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 30439 bytes)

The Request

Wouldn't be nice WordPress customizer analyze the ajax response for PHP fatal errors and promt a message to the user about the process interrupted.

Depends on #35210, notification area.

Attachments (1)

notification-when-saving-fails.png (63.3 KB) - added by westonruter 7 years ago.

Download all attachments as: .zip

Change History (13)

#1 @ocean90
9 years ago

  • Description modified (diff)

#2 @westonruter
9 years ago

  • Milestone changed from Awaiting Review to Future Release


This is largely a duplicate of #29932, but that ticket is more for catchable errors, whereas this issue is for reporting fatal errors.

#3 @swissspidy
8 years ago

  • Keywords needs-patch added

#4 @westonruter
8 years ago

We need a good place to show error messages in the Customizer. @melchoyce and @michaelarestad any ideas? Any error message facility can then be used not only for fatal errors on the server, but also we can use it for showing validation messages in #34893.

#5 @melchoyce
8 years ago

@westonruter I see you're chatting about a design in #31582 — will reply over there.

#6 @westonruter
8 years ago

  • Description modified (diff)

#7 @westonruter
8 years ago

  • Milestone changed from Future Release to 4.6

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.

8 years ago

#9 @celloexpressions
8 years ago

  • Milestone changed from 4.6 to Future Release

Punting since we still need a patch and #35210 is still pending.

This ticket was mentioned in Slack in #core-customize by melchoyce. View the logs.

7 years ago

#11 @westonruter
7 years ago

  • Milestone changed from Future Release to 4.9
  • Owner set to westonruter
  • Status changed from new to accepted

I'm working on this now as part of #35210. See notification-when-saving-fails.png for preview.

#12 @westonruter
7 years ago

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

In 41374:

Customize: Add global notifications area.

  • Displays an error notification in the global area when a save attempt is rejected due to invalid settings. An error notification is also displayed when saving fails due to a network error or server error.
  • Introduces wp.customize.Notifications subclass of wp.customize.Values to contain instances of wp.customize.Notification and manage their rendering into a container.
  • Exposes the global notification area as wp.customize.notifications collection instance.
  • Updates the notifications object on Control to use Notifications rather than Values and to re-use the rendering logic from the former. The old Control#renderNotifications method is deprecated.
  • Allows notifications to be dismissed by instantiating them with a dismissible property.
  • Allows wp.customize.Notification to be extended with custom templates and render functions.
  • Triggers a removed event on wp.customize.Values instances _after_ a value has been removed from the collection.

Props delawski, westonruter, karmatosed, celloexpressions, Fab1en, melchoyce, Kelderic, afercia, adamsilverstein.
See #34893, #39896.
Fixes #35210, #31582, #37727, #37269.

Note: See TracTickets for help on using tickets.