diff --git a/lib/Api/SearchClient.php b/lib/Api/SearchClient.php index 275c2a2b..c088ea5c 100644 --- a/lib/Api/SearchClient.php +++ b/lib/Api/SearchClient.php @@ -21,6 +21,7 @@ use Algolia\AlgoliaSearch\Model\Search\DeleteByParams; use Algolia\AlgoliaSearch\Model\Search\DictionarySettingsParams; use Algolia\AlgoliaSearch\Model\Search\GetObjectsParams; +use Algolia\AlgoliaSearch\Model\Search\GetTaskResponse; use Algolia\AlgoliaSearch\Model\Search\IndexSettings; use Algolia\AlgoliaSearch\Model\Search\OperationIndexParams; use Algolia\AlgoliaSearch\Model\Search\Rule; @@ -2762,6 +2763,8 @@ public function updateApiKey($key, $apiKey, $requestOptions = []) * @param null|int $maxRetries Maximum number of retries * @param null|int $timeout Timeout * + * @return GetTaskResponse + * * @throws ExceededRetriesException */ public function waitForTask($indexName, $taskId, $requestOptions = [], $maxRetries = null, $timeout = null) @@ -2774,7 +2777,7 @@ public function waitForTask($indexName, $taskId, $requestOptions = [], $maxRetri $maxRetries = $this->config->getDefaultMaxRetries(); } - Helpers::retryUntil( + return Helpers::retryUntil( $this, 'getTask', [$indexName, $taskId, $requestOptions], @@ -2792,6 +2795,8 @@ function ($res) {return 'published' === $res['status']; }, * @param null|int $maxRetries Maximum number of retries * @param null|int $timeout Timeout * + * @return GetTaskResponse + * * @throws ExceededRetriesException */ public function waitForAppTask($taskId, $requestOptions = [], $maxRetries = null, $timeout = null) @@ -2804,7 +2809,7 @@ public function waitForAppTask($taskId, $requestOptions = [], $maxRetries = null $maxRetries = $this->config->getDefaultMaxRetries(); } - Helpers::retryUntil( + return Helpers::retryUntil( $this, 'getAppTask', [$taskId, $requestOptions], diff --git a/lib/Support/Helpers.php b/lib/Support/Helpers.php index 7b0b22f0..cda8e7d3 100644 --- a/lib/Support/Helpers.php +++ b/lib/Support/Helpers.php @@ -85,6 +85,8 @@ public static function json_decode($json, $assoc = false, $depth = 512) * @param int $timeout Timeout * @param string $timeoutCalculation name of the method to call to calculate the timeout * + * @return object the last result of the function + * * @throws ExceededRetriesException */ public static function retryUntil( @@ -103,11 +105,11 @@ public static function retryUntil( $res = call_user_func_array([$object, $function], $args); if ($validate($res)) { - return; + return $res; } } catch (\Exception $e) { // if the task is interrupted, just return - return; + return null; } ++$retry;