Changeset 9107 for sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/meetup/class-api-client.php
- Timestamp:
- 08/17/2019 12:35:04 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/meetup/class-api-client.php
r9100 r9107 37 37 */ 38 38 protected $breaking_response_codes = []; 39 40 /** 41 * @var string|null The URL for the current request being attempted. 42 */ 43 protected $current_request_url = null; 44 45 /** 46 * @var array|null The args for the current request being attempted. 47 */ 48 protected $current_request_args = null; 39 49 40 50 /** … … 86 96 } 87 97 98 // Set current request in state so it can be manipulated between request attempts if necessary. 99 $this->current_request_url = $url; 100 $this->current_request_args = $args; 101 88 102 while ( $attempt_count < $max_attempts ) { 89 $response = wp_remote_request( $ url, $args );103 $response = wp_remote_request( $this->current_request_url, $this->current_request_args ); 90 104 $response_code = wp_remote_retrieve_response_code( $response ); 91 105 … … 118 132 * @param int $max_attempts 119 133 */ 120 do_action( 'api_client_tenacious_remote_request_attempt', $response, compact( 'url', 'args' ), $attempt_count, $max_attempts ); 134 do_action( 135 'api_client_tenacious_remote_request_attempt', 136 $response, 137 array( 138 'url' => $this->current_request_url, 139 'args' => $this->current_request_args, 140 ), 141 $attempt_count, 142 $max_attempts 143 ); 121 144 122 145 if ( $attempt_count < $max_attempts ) { … … 129 152 } 130 153 } 154 155 // Reset current request. 156 $this->current_request_url = null; 157 $this->current_request_args = null; 131 158 132 159 if ( $attempt_count === $max_attempts && ( 200 !== $response_code || is_wp_error( $response ) ) ) { … … 225 252 226 253 /** 254 * Merge two error objects into one, new error object. 255 * 256 * @param WP_Error $error1 An error object. 257 * @param WP_Error $error2 An error object. 258 * 259 * @return WP_Error The combined errors of the two parameters. 260 */ 261 protected function merge_errors( WP_Error $error1, WP_Error $error2 ) { 262 $codes = $error2->get_error_codes(); 263 264 foreach ( $codes as $code ) { 265 $messages = $error2->get_error_messages( $code ); 266 267 foreach ( $messages as $message ) { 268 $error1->add( $code, $message ); 269 } 270 } 271 272 return $error1; 273 } 274 275 /** 227 276 * Outputs a message when the command is run from the PHP command line. 228 277 *
Note: See TracChangeset
for help on using the changeset viewer.