Changeset 10293 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/jetpack-search.php
- Timestamp:
- 09/29/2020 12:37:30 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/jetpack-search.php
r10228 r10293 194 194 */ 195 195 protected function error_volume_is_low() { 196 // This cache key keeps a global-ish count of recent errors (per memcache instance).196 // This cache key keeps a global-ish count of recent errors. 197 197 // Used for random exponential backoff when errors start to pile up, as they will if there is a network outage for example. 198 198 $error_volume = max( $this->get_error_volume(), 0 ); // >= 0 … … 251 251 // If the error volume is high, there's a proportionally lower chance that we'll actually attempt to hit the API. 252 252 if ( $this->error_volume_is_low() ) { 253 $ request = wp_remote_post( $service_url,array(253 $service_args = array( 254 254 'headers' => array( 255 255 'Content-Type' => 'application/json', … … 258 258 'user-agent' => 'WordPress.org/jetpack_search', 259 259 'body' => $json_es_args, 260 ) ); 260 ); 261 $request = wp_remote_post( $service_url, $service_args ); 261 262 } else { 262 263 trigger_error( 'Plugin directory search: skipping search due to high error volume', E_USER_WARNING ); 263 264 // Hopefully we still have a cached response to return 264 265 return $response; 266 } 267 268 // Retry 400 responses if the error volume is still low. 269 // These 400's are not bad requests but rather timeouts between the API and ES 270 if ( 400 === wp_remote_retrieve_response_code( $request ) ) { 271 // Bump the error counter 272 $this->increment_error_volume(); 273 274 if ( $this->error_volume_is_low() ) { 275 $request = wp_remote_post( $service_url, $service_args ); 276 } 265 277 } 266 278
Note: See TracChangeset
for help on using the changeset viewer.