Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only silence REST errors if the REST server is added #10903

Merged
merged 2 commits into from
Oct 23, 2018

Conversation

georgeh
Copy link
Contributor

@georgeh georgeh commented Oct 22, 2018

Description

If the REST server is not available in a code run, Gutenberg will fatal with Fatal error: Uncaught Error: Call to undefined function gutenberg_silence_rest_errors()

How has this been tested?

Tested with the 4.1-RC1 plugin on an environment that only loads the REST server for REST requests. Tested by going to /wp-admin and confirming that the page loads without a fatal error.

Types of changes

gutenberg_silence_rest_errors() is called in gutenberg.php in gutenberg_pre_init. The function is defined in lib/rest-api.php, which is only loaded in load.php if class_exists( 'WP_REST_Controller' ).

This PR adds the same class_exists() test to the call to gutenberg_silence_rest_errors() in gutenberg.php.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

George Hotelling added 2 commits October 22, 2018 12:08
If the REST server is not available in a code run, Gutenberg will fatal with `Fatal error: Uncaught Error: Call to undefined function gutenberg_silence_rest_errors()`

`gutenberg_silence_rest_errors` is defined in `lib/rest-api.php`, which is only loaded if `class_exists( 'WP_REST_Controller' )` in `load.php`.

This PR adds the same `class_exists()` test to the call to `gutenberg_silence_rest_errors()` in `gutenberg.php`.
@mkaz
Copy link
Member

mkaz commented Oct 22, 2018

This look good 👍
My only suggestion is maybe add an inline comment on why the function may not exist.

@georgeh georgeh merged commit 1232f8f into master Oct 23, 2018
@georgeh georgeh deleted the fix/fatal-silence-rest-errors branch October 23, 2018 18:04
@youknowriad youknowriad added this to the 4.2 milestone Oct 24, 2018
antpb pushed a commit to antpb/gutenberg that referenced this pull request Oct 26, 2018
* Only silence REST errors if the REST server is added

If the REST server is not available in a code run, Gutenberg will fatal with `Fatal error: Uncaught Error: Call to undefined function gutenberg_silence_rest_errors()`

`gutenberg_silence_rest_errors` is defined in `lib/rest-api.php`, which is only loaded if `class_exists( 'WP_REST_Controller' )` in `load.php`.

This PR adds the same `class_exists()` test to the call to `gutenberg_silence_rest_errors()` in `gutenberg.php`.
@mtias mtias added [Type] Bug An existing feature does not function as intended REST API Interaction Related to REST API labels Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REST API Interaction Related to REST API [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants