WordPress.org

Making WordPress.org

Changeset 9854


Ignore:
Timestamp:
05/12/2020 06:58:10 PM (3 months ago)
Author:
coreymckrill
Message:

Official WP Events: Prevent cronjob from continuing when API returns error

The mark_deleted_meetups routine makes a separate request to the Meetup
API for every group that has upcoming events. However, if one of the requests
returns an error that indicates a problem with the request on our end, it's
very unlikely that subsequent requests will succeed. Further work still needs to
be done in the API client to handle specific error codes so that we don't have
to bail completely, but this hopefully prevents us from continuing to hammer
the API with bad requests that then get our IP marked as "suspicious".

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/official-wordpress-events.php

    r9786 r9854  
    776776            // Make sure we have a valid API response, to avoid marking events as deleted just because the request failed.
    777777            if ( is_wp_error( $events ) ) {
     778                $breaking_error_codes = array( 'invalid_grant', 'auth_fail' );
     779                if ( in_array( $events->get_error_code(), $breaking_error_codes, true ) ) {
     780                    $this->log(
     781                        sprintf(
     782                            'Failed to check for deleted meetup events: %s',
     783                            esc_html( $events->get_error_message() )
     784                        ),
     785                        true
     786                    );
     787                    break;
     788                }
     789
    778790                continue;
    779791            }
Note: See TracChangeset for help on using the changeset viewer.