Skip to content

Commit 6cc8e4c

Browse files
committed
fix: call deprecated curl_close() only on PHP 7.4
1 parent a354c55 commit 6cc8e4c

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/Redmine/Client/NativeCurlClient.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,11 @@ private function runRequest(string $method, string $path, string $body = '', str
309309

310310
if (CURLE_OK !== $curlErrorNumber) {
311311
$e = new ClientException(curl_error($curl), $curlErrorNumber);
312-
curl_close($curl);
312+
313+
if (PHP_VERSION_ID < 80000) {
314+
curl_close($curl);
315+
}
316+
313317
throw $e;
314318
}
315319

@@ -321,7 +325,9 @@ private function runRequest(string $method, string $path, string $body = '', str
321325
$this->lastResponseContentType = $possibleContentType;
322326
}
323327

324-
curl_close($curl);
328+
if (PHP_VERSION_ID < 80000) {
329+
curl_close($curl);
330+
}
325331

326332
return $this->lastResponseStatusCode < 400;
327333
}

tests/RedmineExtension/RedmineInstance.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ private function runHealthChecks(RedmineVersion $version): void
105105
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
106106
$data = curl_exec($ch);
107107
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
108-
curl_close($ch);
108+
if (PHP_VERSION_ID < 80000) {
109+
curl_close($ch);
110+
}
109111

110112
if ($data === false || $statusCode !== 200) {
111113
throw new InvalidArgumentException(sprintf(

0 commit comments

Comments
 (0)