From ff8cb42e2dc2cb1e909248691284098ae8e22755 Mon Sep 17 00:00:00 2001 From: wmwlwmwl <168271477+wmwlwmwl@users.noreply.github.com> Date: Sun, 28 Jun 2026 18:13:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=E5=BA=9F=E5=BC=83?= =?UTF-8?q?=E7=9A=84=20curl=5Fclose()=20=E8=B0=83=E7=94=A8=EF=BC=8C?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=20PHP=208.5=20(#498)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 18 个文件中共 32 处 curl_close() 调用(PHP 8.0+ 已为无操作) - 修复 ACMEv2.php 中 $code 可能为 null 的潜在问题 - 调整 public/.htaccess 伪静态规则,兼容 Windows + CGI 模式 --- app/lib/acme/ACMEv2.php | 5 ++--- app/lib/client/AWS.php | 2 -- app/lib/client/Aliyun.php | 2 -- app/lib/client/AliyunNew.php | 2 -- app/lib/client/AliyunOSS.php | 2 -- app/lib/client/BaiduCloud.php | 2 -- app/lib/client/Ctyun.php | 2 -- app/lib/client/HuaweiCloud.php | 2 -- app/lib/client/HuaweiOBS.php | 2 -- app/lib/client/Jdcloud.php | 2 -- app/lib/client/Ksyun.php | 2 -- app/lib/client/Qiniu.php | 2 -- app/lib/client/TencentCloud.php | 2 -- app/lib/client/Volcengine.php | 2 -- app/lib/deploy/k8s.php | 1 - app/lib/deploy/s3storage.php | 2 -- app/lib/mail/Sendcloud.php | 1 - app/utils/MsgNotice.php | 1 - public/.htaccess | 4 +++- 19 files changed, 5 insertions(+), 35 deletions(-) diff --git a/app/lib/acme/ACMEv2.php b/app/lib/acme/ACMEv2.php index 0bfbe8c..b263ad7 100644 --- a/app/lib/acme/ACMEv2.php +++ b/app/lib/acme/ACMEv2.php @@ -29,7 +29,6 @@ class ACMEv2 public function __destruct() { if (PHP_MAJOR_VERSION < 8 && $this->account_key) openssl_pkey_free($this->account_key); - if ($this->ch) curl_close($this->ch); } public function loadAccountKey($account_key_pem) @@ -377,7 +376,7 @@ class ACMEv2 if (!empty($headers['content-type'])) { switch ($headers['content-type']) { case 'application/json': - if ($code[0] == '2') { // on non 2xx response: fall through to problem+json case + if (!is_null($code) && $code[0] == '2') { // on non 2xx response: fall through to problem+json case $body = $this->json_decode($body); if (isset($body['error']) && !(isset($body['status']) && $body['status'] === 'valid')) { $this->handleError($body['error']); @@ -391,7 +390,7 @@ class ACMEv2 } } - if ($code[0] != '2') { + if (!is_null($code) && $code[0] != '2') { throw new Exception('Invalid HTTP-Status-Code received: ' . $code . ': ' . print_r($body, true)); } diff --git a/app/lib/client/AWS.php b/app/lib/client/AWS.php index 634e268..6f67f66 100644 --- a/app/lib/client/AWS.php +++ b/app/lib/client/AWS.php @@ -286,7 +286,6 @@ class AWS $errno = curl_errno($ch); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); @@ -297,7 +296,6 @@ class AWS $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $response = substr($response, $headerSize); } - curl_close($ch); if ($httpCode >= 200 && $httpCode < 300) { if (empty($response)) return true; diff --git a/app/lib/client/Aliyun.php b/app/lib/client/Aliyun.php index 9ad9efe..185ec6d 100644 --- a/app/lib/client/Aliyun.php +++ b/app/lib/client/Aliyun.php @@ -63,10 +63,8 @@ class Aliyun $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } - curl_close($ch); $arr = json_decode($response, true); if ($httpCode == 200) { diff --git a/app/lib/client/AliyunNew.php b/app/lib/client/AliyunNew.php index f3dd8ce..17c5625 100644 --- a/app/lib/client/AliyunNew.php +++ b/app/lib/client/AliyunNew.php @@ -169,11 +169,9 @@ class AliyunNew $errno = curl_errno($ch); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - curl_close($ch); $arr = json_decode($response, true); if ($httpCode == 200) { diff --git a/app/lib/client/AliyunOSS.php b/app/lib/client/AliyunOSS.php index 5ad4e70..45252f8 100644 --- a/app/lib/client/AliyunOSS.php +++ b/app/lib/client/AliyunOSS.php @@ -120,10 +120,8 @@ class AliyunOSS $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } - curl_close($ch); if ($httpCode >= 200 && $httpCode < 300) { if (empty($response)) return true; diff --git a/app/lib/client/BaiduCloud.php b/app/lib/client/BaiduCloud.php index 6da15c2..a1be297 100644 --- a/app/lib/client/BaiduCloud.php +++ b/app/lib/client/BaiduCloud.php @@ -159,10 +159,8 @@ class BaiduCloud $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } - curl_close($ch); if (empty($response) && $httpCode == 200) { return true; diff --git a/app/lib/client/Ctyun.php b/app/lib/client/Ctyun.php index 1be035e..3f92137 100644 --- a/app/lib/client/Ctyun.php +++ b/app/lib/client/Ctyun.php @@ -150,10 +150,8 @@ class Ctyun $errno = curl_errno($ch); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } - curl_close($ch); $arr = json_decode($response, true); if (isset($arr['statusCode']) && ($arr['statusCode'] == 100000 || $arr['statusCode'] == 0 && $this->endpoint == 'cf-global.ctapi.ctyun.cn')) { diff --git a/app/lib/client/HuaweiCloud.php b/app/lib/client/HuaweiCloud.php index 2e8391c..ee0802c 100644 --- a/app/lib/client/HuaweiCloud.php +++ b/app/lib/client/HuaweiCloud.php @@ -164,11 +164,9 @@ class HuaweiCloud $errno = curl_errno($ch); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - curl_close($ch); $arr = json_decode($response, true); if ($arr) { diff --git a/app/lib/client/HuaweiOBS.php b/app/lib/client/HuaweiOBS.php index dbd7def..17ad414 100644 --- a/app/lib/client/HuaweiOBS.php +++ b/app/lib/client/HuaweiOBS.php @@ -107,10 +107,8 @@ class HuaweiOBS $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } - curl_close($ch); if ($httpCode >= 200 && $httpCode < 300) { if (empty($response)) return true; diff --git a/app/lib/client/Jdcloud.php b/app/lib/client/Jdcloud.php index d45523e..ef6c689 100644 --- a/app/lib/client/Jdcloud.php +++ b/app/lib/client/Jdcloud.php @@ -168,11 +168,9 @@ class Jdcloud $errno = curl_errno($ch); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - curl_close($ch); $arr = json_decode($response, true); if ($httpCode == 200) { diff --git a/app/lib/client/Ksyun.php b/app/lib/client/Ksyun.php index a1c5341..5def247 100644 --- a/app/lib/client/Ksyun.php +++ b/app/lib/client/Ksyun.php @@ -189,11 +189,9 @@ class Ksyun $errno = curl_errno($ch); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - curl_close($ch); $arr = json_decode($response, true); if ($httpCode == 200) { diff --git a/app/lib/client/Qiniu.php b/app/lib/client/Qiniu.php index a9096e0..fc1f79b 100644 --- a/app/lib/client/Qiniu.php +++ b/app/lib/client/Qiniu.php @@ -122,10 +122,8 @@ class Qiniu $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } - curl_close($ch); if ($httpCode == 200) { $arr = json_decode($response, true); diff --git a/app/lib/client/TencentCloud.php b/app/lib/client/TencentCloud.php index 6571f54..67934d7 100644 --- a/app/lib/client/TencentCloud.php +++ b/app/lib/client/TencentCloud.php @@ -114,10 +114,8 @@ class TencentCloud $errno = curl_errno($ch); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } - curl_close($ch); $arr = json_decode($response, true); if ($arr) { diff --git a/app/lib/client/Volcengine.php b/app/lib/client/Volcengine.php index 25df322..4a3ae6e 100644 --- a/app/lib/client/Volcengine.php +++ b/app/lib/client/Volcengine.php @@ -219,11 +219,9 @@ class Volcengine $errno = curl_errno($ch); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - curl_close($ch); $arr = json_decode($response, true); if ($httpCode == 200) { diff --git a/app/lib/deploy/k8s.php b/app/lib/deploy/k8s.php index a67830e..b7f275c 100644 --- a/app/lib/deploy/k8s.php +++ b/app/lib/deploy/k8s.php @@ -175,7 +175,6 @@ class k8s implements DeployInterface $resp = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); $err = curl_error($ch); - curl_close($ch); return [$code, $resp, $err]; } diff --git a/app/lib/deploy/s3storage.php b/app/lib/deploy/s3storage.php index 6654b79..95b7707 100644 --- a/app/lib/deploy/s3storage.php +++ b/app/lib/deploy/s3storage.php @@ -105,11 +105,9 @@ class s3storage implements DeployInterface $errno = curl_errno($ch); if ($errno) { $errmsg = curl_error($ch); - curl_close($ch); throw new Exception('Curl error: ' . $errmsg); } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - curl_close($ch); if ($httpCode >= 200 && $httpCode < 300) { return $response; diff --git a/app/lib/mail/Sendcloud.php b/app/lib/mail/Sendcloud.php index 35c8c8d..18bae5d 100644 --- a/app/lib/mail/Sendcloud.php +++ b/app/lib/mail/Sendcloud.php @@ -31,7 +31,6 @@ class Sendcloud curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $json = curl_exec($ch); - curl_close($ch); $arr = json_decode($json, true); if ($arr['statusCode'] == 200) { return true; diff --git a/app/utils/MsgNotice.php b/app/utils/MsgNotice.php index e26201e..2292d1f 100644 --- a/app/utils/MsgNotice.php +++ b/app/utils/MsgNotice.php @@ -468,7 +468,6 @@ class MsgNotice curl_setopt($ch, CURLOPT_ENCODING, "gzip"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $ret = curl_exec($ch); - curl_close($ch); return $ret; } } diff --git a/public/.htaccess b/public/.htaccess index d28d3bd..c0a1590 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -1,9 +1,11 @@ Options +FollowSymlinks -Multiviews RewriteEngine On + RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] + RewriteRule ^(.*)$ index.php [L,QSA,E=PATH_INFO:/$1] + SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1