Following code throws an error "paremeter 4 &$options expected to be a reference, value given"
This code is from guzzle_retry_middleware#on-retry-callback
I wanted to stop the guzzle retry call after receiving self::STATUS_DRAFT === $document->status with response 200
$listener = function(int $attemptNumber, float $delay, RequestInterface $request, array &$options, ?ResponseInterface $response)
{
$document = \json_decode();
if (self::STATUS_DRAFT === $document->status)
{
return $options['retry_enabled'] = false;
}
};
$stack = HandlerStack::create();
$stack->push(GuzzleRetryMiddleware::factory([
'on_retry_callback' => $listener,
'retry_on_status' =>[429, 503, 200]
]));
$response = $guzzleClient->get($url, ['handler' => $stack]);
This test code seems to work fine for me. I created a request that just randomly spits out a number, which is used in the retry callback.
I'm using PHP 7.3 and the latest version of Guzzle and the middleware. If you're getting an error about the
$optionsvariable, try isolating this code on your environment and confirm there's no version mismatch.And I get this response
Here's my composer.json file