WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 22 months ago

#38270 new enhancement

Better handling of widget errors

Reported by: dustwolf Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7
Component: Widgets Keywords: close
Focuses: Cc:

Description

This change makes debugging broken widgets a lot less painful -- in case of errors in widgets this will allow the site to load and the developer to see the error messages instead of just blowing up with the ambiguous error message "Class not defined".

https://github.com/WordPress/WordPress/pull/207#issuecomment-252338814

Attachments (1)

134043eb91d1d6a560130a5d06237af5b1173c39.patch (1.1 KB) - added by dustwolf 4 years ago.
Patch

Download all attachments as: .zip

Change History (3)

#1 @westonruter
4 years ago

  • Keywords close added

Thanks for the suggestion. However, I don't think this is an improvement because if the class doesn't exist then there will be no error at all, no indication that there is a problem other than the widget not showing up. On the other hand, if attempting to create a new instance of a class that doesn't exist, then the developer will know right away that they forgot to add the necessary require_once statement.

#2 @dustwolf
4 years ago

With the original code, if there is an error, the page comes up blank and there is no indication what the problem may be. With my patch, the page loads, but the functionality of the offending widget is conspicuously missing. The solution is not perfect, but it doesn't take much to determine the lesser of two evils.

Furthermore with the existing code, if an end-user installs a widget with broken code, they get a blank page and cannot so much as uninstall the offending widget (without tweaking the database directly) because the interface is not accessible. If on the other hand they install a broken widget and it does not show up, they can understand that it doesn't work and remove it.

Last edited 4 years ago by dustwolf (previous) (diff)
Note: See TracTickets for help on using tickets.