Skip to content

Commit 322edde

Browse files
Only call curl_close() on PHP < 8 (#4125)
* Only call curl_close() in PHP < 8 * Patch Httpie.php to only call curl_close() in PHP < 8
1 parent 8206661 commit 322edde

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

contrib/cloudflare.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@
6666
throw new \RuntimeException("Error making curl request (result: $res)");
6767
}
6868

69-
curl_close($ch);
69+
if (PHP_MAJOR_VERSION < 8) {
70+
curl_close($ch);
71+
}
7072

7173
return $res;
7274
};

src/Command/InitCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
115115
curl_setopt(\$ch, CURLOPT_CONNECTTIMEOUT, 5);
116116
curl_setopt(\$ch, CURLOPT_TIMEOUT, 5);
117117
\$result = curl_exec(\$ch);
118-
curl_close(\$ch);
118+
if (PHP_MAJOR_VERSION < 8) {
119+
curl_close(\$ch);
120+
}
119121
\$json = json_decode(\$result);
120122
\$host = parse_url(\$json->blog, PHP_URL_HOST);
121123
file_put_contents('$tempHostFile', \$host);

src/Support/Reporter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ public static function report(array $stats): void
4040
curl_setopt(\$ch, CURLOPT_CONNECTTIMEOUT, 5);
4141
curl_setopt(\$ch, CURLOPT_TIMEOUT, 5);
4242
\$result = curl_exec(\$ch);
43-
curl_close(\$ch);
43+
if (PHP_MAJOR_VERSION < 8) {
44+
curl_close(\$ch);
45+
}
4446
EOF);
4547
$php->start();
4648
}

src/Utility/Httpie.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,15 @@ public function send(?array &$info = null): string
158158
} else {
159159
$error = curl_error($ch);
160160
$errno = curl_errno($ch);
161-
curl_close($ch);
161+
if (PHP_MAJOR_VERSION < 8) {
162+
curl_close($ch);
163+
}
162164
throw new HttpieException($error, $errno);
163165
}
164166
}
165-
curl_close($ch);
167+
if (PHP_MAJOR_VERSION < 8) {
168+
curl_close($ch);
169+
}
166170
return $result;
167171
}
168172

0 commit comments

Comments
 (0)