Skip to content

Commit 48a59b0

Browse files
committed
fix(php): pass linear timeout and return response
1 parent e31f32b commit 48a59b0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

clients/algoliasearch-client-php/lib/Support/Helpers.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ public static function retryForApiKeyUntil(
151151

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

157157
// In case of an update, check if the key has been updated as it should be
158158
if ('update' === $operation) {
159159
if (self::isKeyUpdated($response, $apiKey)) {
160-
return;
160+
return $response;
161161
}
162162
}
163163

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

174174
// Else try again ...

templates/php/api.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,14 +389,14 @@ use {{invokerPackage}}\Support\Helpers;
389389
$maxRetries = $this->config->getDefaultMaxRetries();
390390
}
391391

392-
Helpers::retryForApiKeyUntil(
392+
return Helpers::retryForApiKeyUntil(
393393
$operation,
394394
$this,
395395
$key,
396396
$apiKey,
397397
$maxRetries,
398398
$timeout,
399-
null,
399+
'Algolia\AlgoliaSearch\Support\Helpers::linearTimeout',
400400
$requestOptions
401401
);
402402
}

0 commit comments

Comments
 (0)