Skip to content

Commit 4885d13

Browse files
fix: Only call curl_close() in PHP < 8 (#1947)
1 parent 775c7ac commit 4885d13

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/HttpClient/HttpClient.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ public function sendRequest(Request $request, Options $options): Response
106106
if ($body === false) {
107107
$errorCode = curl_errno($curlHandle);
108108
$error = curl_error($curlHandle);
109-
curl_close($curlHandle);
109+
if (\PHP_MAJOR_VERSION < 8) {
110+
curl_close($curlHandle);
111+
}
110112

111113
$message = 'cURL Error (' . $errorCode . ') ' . $error;
112114

@@ -115,7 +117,9 @@ public function sendRequest(Request $request, Options $options): Response
115117

116118
$statusCode = curl_getinfo($curlHandle, \CURLINFO_HTTP_CODE);
117119

118-
curl_close($curlHandle);
120+
if (\PHP_MAJOR_VERSION < 8) {
121+
curl_close($curlHandle);
122+
}
119123

120124
$error = $statusCode >= 400 ? $body : '';
121125

src/Spotlight/SpotlightClient.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ public static function sendRequest(Request $request, string $url): Response
4242
if ($body === false) {
4343
$errorCode = curl_errno($curlHandle);
4444
$error = curl_error($curlHandle);
45-
curl_close($curlHandle);
45+
if (\PHP_MAJOR_VERSION < 8) {
46+
curl_close($curlHandle);
47+
}
4648

4749
$message = 'cURL Error (' . $errorCode . ') ' . $error;
4850

@@ -51,7 +53,9 @@ public static function sendRequest(Request $request, string $url): Response
5153

5254
$statusCode = curl_getinfo($curlHandle, \CURLINFO_HTTP_CODE);
5355

54-
curl_close($curlHandle);
56+
if (\PHP_MAJOR_VERSION < 8) {
57+
curl_close($curlHandle);
58+
}
5559

5660
return new Response($statusCode, [], '');
5761
}

0 commit comments

Comments
 (0)