瀏覽代碼

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.
Ahmet Soormally 10 年之前
父節點
當前提交
7f0cc89685
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      src/Monolog/Handler/Curl/Util.php

+ 8 - 2
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;