Make WordPress Core

Changeset 45504

Timestamp:
06/08/2019 05:09:02 PM (5 years ago)
Author:
johnbillion
Message:

HTTP API: Ensure the http_api_debug hook is fired for all responses.

This means that logging and debugging functionality can access the error code and error message for erroneous responses under all conditions. The hook is not fired when a request is short-circuited with the pre_http_request filter, because this filter itself can be used in that situation.

Fixes #25747

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-http.php

    r45135 r45504  
    273273
    274274        if ( empty( $url ) || empty( $arrURL['scheme'] ) ) {
    275             return new WP_Error( 'http_request_failed', __( 'A valid URL was not provided.' ) );
     275            $response = new WP_Error( 'http_request_failed', __( 'A valid URL was not provided.' ) );
     276            /** This action is documented in wp-includes/class-http.php */
     277            do_action( 'http_api_debug', $response, 'response', 'Requests', $r, $url );
     278            return $response;
    276279        }
    277280
    278281        if ( $this->block_request( $url ) ) {
    279             return new WP_Error( 'http_request_failed', __( 'User has blocked requests through HTTP.' ) );
     282            $response = new WP_Error( 'http_request_not_executed', __( 'User has blocked requests through HTTP.' ) );
     283            /** This action is documented in wp-includes/class-http.php */
     284            do_action( 'http_api_debug', $response, 'response', 'Requests', $r, $url );
     285            return $response;
    280286        }
    281287
     
    290296            $r['blocking'] = true;
    291297            if ( ! wp_is_writable( dirname( $r['filename'] ) ) ) {
    292                 return new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );
     298                $response = new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );
     299                /** This action is documented in wp-includes/class-http.php */
     300                do_action( 'http_api_debug', $response, 'response', 'Requests', $r, $url );
     301                return $response;
    293302            }
    294303        }
Note: See TracChangeset for help on using the changeset viewer.