Skip to content

Commit

Permalink
Fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuLamiot committed Jun 28, 2024
1 parent 4a8fa3f commit 6fcb948
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ private function send_request( $method, $params = [], $safe = false ) {
if ( get_transient( $transient_key . '_timeout_active' ) ) {
return new WP_Error( 429, __( 'Too many requests.', 'rocket' ) );
}
# Get previous_expiration early to avoid multiple parallel requests increasing the expiration multiple times
// Get previous_expiration early to avoid multiple parallel requests increasing the expiration multiple times.
$previous_expiration = (int) get_transient( $transient_key . '_timeout' );

$params['method'] = strtoupper( $method );

$response = $this->send_remote_request( $api_url, $method, $params, $safe );

if ( is_wp_error( $response ) ) {
$this->set_timeout_transients($previous_expiration);
$this->set_timeout_transients( $previous_expiration );
return $response;
}

$body = wp_remote_retrieve_body( $response );
if ( empty( $body ) || ( is_array( $response ) && ! empty( $response['response']['code'] ) && 200 !== $response['response']['code'] ) ) {
$this->set_timeout_transients($previous_expiration);
$this->set_timeout_transients( $previous_expiration );
return new WP_Error( 500, __( 'Not valid response.', 'rocket' ) );
}

Expand All @@ -92,10 +92,10 @@ private function send_request( $method, $params = [], $safe = false ) {

/**
* Set the timeout transients.
*
* @param string $previous_expiration The previous value of _timeout_active transient
*
* @param string $previous_expiration The previous value of _timeout_active transient.
*/
private function set_timeout_transients($previous_expiration) {
private function set_timeout_transients( $previous_expiration ) {
$transient_key = $this->get_transient_key();

$expiration = ( 0 === $previous_expiration )
Expand Down

0 comments on commit 6fcb948

Please sign in to comment.