Skip to content

Commit 1181a65

Browse files
committed
Fix curl_close() deprecation
Stole code from safe_curl_close function in core. Thanks, mwr for the report..
1 parent 1e5b14a commit 1181a65

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/templates/forms/misc/repo_link_github.txp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,19 @@ curl_setopt_array($curl, [
4747
]);
4848

4949
$response = curl_exec($curl);
50-
curl_close($curl);
50+
51+
if ($curl instanceof CurlHandle) {
52+
// PHP 8.0+ returns CurlHandle objects
53+
// In 8.5+ curl_close() is deprecated, so just nullify
54+
$curl = null;
55+
} elseif (is_resource($curl) && get_resource_type($curl) === 'curl') {
56+
// Older PHP (< 8.0) used resources
57+
curl_close($curl);
58+
$curl = null;
59+
} else {
60+
// Not a valid cURL handle
61+
$curl = null;
62+
}
5163

5264
if ($response === false) {
5365
return;

0 commit comments

Comments
 (0)