Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Performance indicators - bail whenever an internal API request fails. #2423

Merged
merged 2 commits into from
Jun 14, 2019

Conversation

jeffstieler
Copy link
Contributor

Fixes #2288

When using rest_do_request() internally, add handling for cases where a WP_Error is returned.

Detailed test instructions:

Use the following snippet to force the error condition:

add_filter( 'rest_pre_dispatch', function( $pre, $server, $request ) {
        if (
            'GET' === $request->get_method() &&
            '/wc/v4/reports' === $request->get_route()
        ) {
            return new WP_Error( 'bam', 'pow' );
        }

        return $pre;
}, 10, 3 );
  • On master, verify the error shows up in the logs when visiting the Dashboard
  • Check out this branch
  • Verify the error no longer occurs in log when visiting the Dashboard (Performance Indicators section will be empty though)

Changelog Note:

Fix: handle internal rest_do_request() error conditions.

Copy link
Collaborator

@psealock psealock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, testing as advertised.

@psealock psealock mentioned this pull request Jun 14, 2019
@jeffstieler jeffstieler merged commit 5044e0e into master Jun 14, 2019
@jeffstieler jeffstieler deleted the fix/2288-unhandled-rest-requests-wp-error branch June 14, 2019 15:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REST API: Fatal in Performance Indicators Endpoint
2 participants