Skip to content

Commit

Permalink
fix(php): pass linear timeout and return response
Browse files Browse the repository at this point in the history
  • Loading branch information
Fluf22 committed Jul 12, 2024
1 parent e31f32b commit 48a59b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions clients/algoliasearch-client-php/lib/Support/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ public static function retryForApiKeyUntil(

// In case of an addition, if there was no error, the $key has been added as it should be
if ('add' === $operation) {
return;
return $response;
}

// In case of an update, check if the key has been updated as it should be
if ('update' === $operation) {
if (self::isKeyUpdated($response, $apiKey)) {
return;
return $response;
}
}

Expand All @@ -166,9 +166,9 @@ public static function retryForApiKeyUntil(
// In case of a deletion, if there was an error, the $key has been deleted as it should be
if (
'delete' === $operation
&& 'Key does not exist' === $e->getMessage()
&& $e->getCode() === 404
) {
return;
return null;
}

// Else try again ...
Expand Down
4 changes: 2 additions & 2 deletions templates/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,14 @@ use {{invokerPackage}}\Support\Helpers;
$maxRetries = $this->config->getDefaultMaxRetries();
}

Helpers::retryForApiKeyUntil(
return Helpers::retryForApiKeyUntil(
$operation,
$this,
$key,
$apiKey,
$maxRetries,
$timeout,
null,
'Algolia\AlgoliaSearch\Support\Helpers::linearTimeout',
$requestOptions
);
}
Expand Down

0 comments on commit 48a59b0

Please # to comment.