From 7f0cc89685ae16be7552d3c8b7be32dc7dcf1d29 Mon Sep 17 00:00:00 2001 From: Ahmet Soormally Date: Wed, 29 Jul 2015 11:56:27 +0100 Subject: [PATCH] Update Util.php Fixes bug with error handler. Once `curl_close($ch)` is called, then `curl_errno($ch)` and `curl_error($ch)` makes no sense and will cause an error in the exception handler. --- src/Monolog/Handler/Curl/Util.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Monolog/Handler/Curl/Util.php b/src/Monolog/Handler/Curl/Util.php index 8b56a3ef..d71f0c6f 100644 --- a/src/Monolog/Handler/Curl/Util.php +++ b/src/Monolog/Handler/Curl/Util.php @@ -33,12 +33,18 @@ class Util { while ($retries--) { if (curl_exec($ch) === false) { - if (false === in_array(curl_errno($ch), self::$retriableErrorCodes, true) || !$retries) { + + $curlErrno = curl_errno($ch); + + if (false === in_array($curlErrno, self::$retriableErrorCodes, true) || !$retries) { + + $curlError = curl_error($ch); + if ($closeAfterDone) { curl_close($ch); } - throw new \RuntimeException(sprintf('Curl error (code %s): %s', curl_errno($ch), curl_error($ch))); + throw new \RuntimeException(sprintf('Curl error (code %s): %s', $curlErrno, $curlError)); } continue;