diff --git a/src/Illuminate/Support/helpers.php b/src/Illuminate/Support/helpers.php index 76d8e85f37e4..16463ba5530b 100755 --- a/src/Illuminate/Support/helpers.php +++ b/src/Illuminate/Support/helpers.php @@ -617,24 +617,17 @@ function preg_replace_array($pattern, array $replacements, $subject) */ function retry($times, callable $callback, $sleep = 0) { - $times--; - - beginning: - try { - return $callback(); - } catch (Exception $e) { - if (! $times) { - throw $e; - } - - $times--; - - if ($sleep) { - usleep($sleep * 1000); + do { + try { + return $callback(); + } catch (Exception $e) { + if ($times > 1 && $sleep > 0) { + usleep($sleep * 1000); + } } + } while (--$times); - goto beginning; - } + throw $e; } }