Skip to content

Improve resilience to PHP Notices and Warnings #4936

Closed

Description

Issue Overview

As mentioned in today's core-editor meeting
I believe that Gutenberg could be significantly improved if it could detect unexpected server responses, especially things like PHP Notices and Warnings

and it should

  1. Ignore them for the purposes of determining what actually happened.
  2. Let the user know about the problem gracefully.

I have experienced a number of situations, where PHP Notices and Warnings get returned along with the validly formed JSON response.

  • Some of these are out of my control.
  • Most of them are good to know about.
  • Especially if you're a developer running with WP_DEBUG true
  • They don't cause a problem with the Classic editor

Steps to Reproduce (for bugs)

  1. Find a plugin or theme that produces Notices or Warnings or simply echoes things when it shouldn't
  2. Add a new post
  3. Use it for a while
  4. Notice Updating Failed messages
  5. Look in the Browser Console log to see unwanted HTML
  6. But notice that the updates did actually work.

For a particularly good example of a misbehaving plugin see https://github.com/bobbingwide/dinlo

Expected Behavior

It would be nice if Gutenberg could filter out what's not part of the JSON response and report the results based on that information.

It would also be nice if it was able to report nicely what the problem was.

Current Behavior

In the classic editor the messages appear. Many are just an annoyance but the editor works.

Possible Solution

Screenshots / Video

Here's the simplest example I could think of.
Add an HTML comment to the top of the gutenberg.php plugin.
<!-- 4936 -->

image

image

Related Issues and/or PRs

Todos

  • Tests
  • Documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions