15m44w 续5c 根治横条消失: 删全仓 curl_close + JSON 端点抑制 deprecation 输出
真根因(推翻 token 过期说): PHP8.5 下 curl_close() 已废弃, 每次调用都输出 <br><b>Deprecated</b> 污染 JSON 响应体 → 前端 res.json() 解析失败进 catch (端点 catch 注释'不显示') → GitHub 授权横条消失。实测 gh_cfg 后端验活 status=200 ok=true 但响应体被警告污染, 非纯 JSON。 修: ① 全仓 8 处独立 curl_close 语句删除(PHP8+ 是 no-op, 出作用域自动关闭, 删了不改行为还消除 deprecation 源头); ② gh_cfg/gh_diag/gh_git_probe 顶部加 error_reporting(0)+display_errors=0 兜底, 彻底防任何警告污染响应体。 实测部署后 gh_cfg.php 返回纯 JSON, gh_authorized=true。
This commit is contained in:
@@ -9,6 +9,10 @@
|
|||||||
*/
|
*/
|
||||||
while (ob_get_level() > 0) { @ob_end_clean(); }
|
while (ob_get_level() > 0) { @ob_end_clean(); }
|
||||||
ob_start();
|
ob_start();
|
||||||
|
// ★ 15m44w 续5c 根治横条消失:PHP8.5 下 deprecation/notice 输出 <br> 污染 JSON 响应体,
|
||||||
|
// 前端 res.json() 解析失败进 catch → 授权横条不显示。抑制一切错误输出保响应体纯净。
|
||||||
|
error_reporting(0);
|
||||||
|
ini_set('display_errors', '0');
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
header('X-Content-Type-Options: nosniff');
|
header('X-Content-Type-Options: nosniff');
|
||||||
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
|
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
*/
|
*/
|
||||||
while (ob_get_level() > 0) { @ob_end_clean(); }
|
while (ob_get_level() > 0) { @ob_end_clean(); }
|
||||||
ob_start();
|
ob_start();
|
||||||
|
// ★ 15m44w 续5c:PHP8.5 下 deprecation/notice 会输出 <br> 污染 JSON 响应体致前端 res.json() 失败,
|
||||||
|
// 抑制一切错误输出,保证响应体纯净(curl_close 已删, 此为其它警告兜底)。
|
||||||
|
error_reporting(0);
|
||||||
|
ini_set('display_errors', '0');
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
header('X-Content-Type-Options: nosniff');
|
header('X-Content-Type-Options: nosniff');
|
||||||
header('Cache-Control: no-store');
|
header('Cache-Control: no-store');
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
*/
|
*/
|
||||||
while (ob_get_level() > 0) { @ob_end_clean(); }
|
while (ob_get_level() > 0) { @ob_end_clean(); }
|
||||||
ob_start();
|
ob_start();
|
||||||
|
// ★ 15m44w 续5c:抑制 deprecation/notice 输出,保 JSON 响应体纯净(PHP8.5)
|
||||||
|
error_reporting(0);
|
||||||
|
ini_set('display_errors', '0');
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
header('Cache-Control: no-store');
|
header('Cache-Control: no-store');
|
||||||
|
|
||||||
@@ -56,7 +59,6 @@ if ($ir['full'] !== '' && $ir['owner'] !== '') {
|
|||||||
curl_exec($ch);
|
curl_exec($ch);
|
||||||
$reachStatus = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
$reachStatus = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
||||||
$reach = 'HTTP ' . $reachStatus;
|
$reach = 'HTTP ' . $reachStatus;
|
||||||
curl_close($ch);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ if ($code !== '') {
|
|||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
||||||
$body = curl_exec($ch);
|
$body = curl_exec($ch);
|
||||||
$errno = curl_errno($ch);
|
$errno = curl_errno($ch);
|
||||||
curl_close($ch);
|
|
||||||
if ($errno) {
|
if ($errno) {
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
echo '<meta charset="utf-8"><p>获取 GitHub token 失败(cURL ' . htmlspecialchars((string)$errno) . ')。</p>';
|
echo '<meta charset="utf-8"><p>获取 GitHub token 失败(cURL ' . htmlspecialchars((string)$errno) . ')。</p>';
|
||||||
|
|||||||
@@ -187,8 +187,7 @@ function msPost($url, $data, $headers = []) {
|
|||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
$error = curl_error($ch);
|
$error = curl_error($ch);
|
||||||
curl_close($ch);
|
// 15m44w 续5c:删 curl_close(PHP8.5 deprecation 污染响应体)
|
||||||
|
|
||||||
// 详细日志记录
|
// 详细日志记录
|
||||||
$log = date('Y-m-d H:i:s') . "\n";
|
$log = date('Y-m-d H:i:s') . "\n";
|
||||||
$log .= "URL: $url\n";
|
$log .= "URL: $url\n";
|
||||||
@@ -225,8 +224,7 @@ function msGet($url, $headers = []) {
|
|||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
$error = curl_error($ch);
|
$error = curl_error($ch);
|
||||||
curl_close($ch);
|
// 15m44w 续5c:删 curl_close(PHP8.5 deprecation 污染响应体)
|
||||||
|
|
||||||
// 详细日志记录
|
// 详细日志记录
|
||||||
$log = date('Y-m-d H:i:s') . "\n";
|
$log = date('Y-m-d H:i:s') . "\n";
|
||||||
$log .= "GET URL: $url\n";
|
$log .= "GET URL: $url\n";
|
||||||
|
|||||||
+2
-3
@@ -629,7 +629,7 @@ function triggerPollerAsync() {
|
|||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
// 不等待结果,后台执行
|
// 不等待结果,后台执行
|
||||||
curl_exec($ch);
|
curl_exec($ch);
|
||||||
curl_close($ch);
|
// 15m44w 续5c:删 curl_close(PHP8.5 deprecation 污染响应体)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====================================================================
|
// ====================================================================
|
||||||
@@ -905,8 +905,7 @@ function queryPlatformAPI($outTradeNo) {
|
|||||||
$err = curl_error($ch);
|
$err = curl_error($ch);
|
||||||
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
$elapsed = curl_getinfo($ch, CURLINFO_TOTAL_TIME);
|
$elapsed = curl_getinfo($ch, CURLINFO_TOTAL_TIME);
|
||||||
curl_close($ch);
|
// 15m44w 续5c:删 curl_close(PHP8.5 deprecation 污染响应体)
|
||||||
|
|
||||||
debugLog('[queryPlatformAPI] curl完成', [
|
debugLog('[queryPlatformAPI] curl完成', [
|
||||||
'http_code' => $code,
|
'http_code' => $code,
|
||||||
'elapsed_s' => round($elapsed, 3),
|
'elapsed_s' => round($elapsed, 3),
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ function wpjFetch($url, $timeout, $referer) {
|
|||||||
CURLOPT_REFERER => $referer,
|
CURLOPT_REFERER => $referer,
|
||||||
));
|
));
|
||||||
$body = curl_exec($ch);
|
$body = curl_exec($ch);
|
||||||
curl_close($ch);
|
// 15m44w 续5c:删 curl_close(PHP8.5 deprecation 污染响应体)
|
||||||
return is_string($body) ? $body : '';
|
return is_string($body) ? $body : '';
|
||||||
}
|
}
|
||||||
$ctx = stream_context_create(array('http' => array(
|
$ctx = stream_context_create(array('http' => array(
|
||||||
|
|||||||
+2
-1
@@ -82,7 +82,8 @@ function ghApiRequest($method, $path, $payload = null, $token = null) {
|
|||||||
$errno = curl_errno($ch);
|
$errno = curl_errno($ch);
|
||||||
$err = curl_error($ch);
|
$err = curl_error($ch);
|
||||||
$status = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
$status = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
||||||
curl_close($ch);
|
// ★ 15m44w 续5c:删 curl_close(PHP8.0+ 是 no-op, 8.5 报 deprecation 警告污染 JSON 响应体,
|
||||||
|
// 致前端 res.json() 解析失败 → GitHub 授权横条消失)。PHP8 下 $ch 出作用域自动关闭。
|
||||||
if ($errno) return ['ok' => false, 'status' => 0, 'msg' => 'cURL ' . $errno . ': ' . $err, 'data' => null];
|
if ($errno) return ['ok' => false, 'status' => 0, 'msg' => 'cURL ' . $errno . ': ' . $err, 'data' => null];
|
||||||
$j = json_decode((string)$body, true);
|
$j = json_decode((string)$body, true);
|
||||||
$msg = (is_array($j) && isset($j['message']) && $j['message'] !== '')
|
$msg = (is_array($j) && isset($j['message']) && $j['message'] !== '')
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ function easyUploadFile($tmpPath, $origName) {
|
|||||||
$errno = curl_errno($ch);
|
$errno = curl_errno($ch);
|
||||||
$err = curl_error($ch);
|
$err = curl_error($ch);
|
||||||
$status = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
$status = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
||||||
curl_close($ch);
|
// 15m44w 续5c:删 curl_close(PHP8.5 deprecation 污染响应体), $ch 出作用域自动关闭
|
||||||
if ($errno) return ['ok' => false, 'msg' => 'cURL错误: ' . $err];
|
if ($errno) return ['ok' => false, 'msg' => 'cURL错误: ' . $err];
|
||||||
$j = json_decode((string)$body, true);
|
$j = json_decode((string)$body, true);
|
||||||
// EasyImages2.0 成功: {result:"success", url:..., thumb:...};失败: {result:"failed", message:...} 或 code!=200
|
// EasyImages2.0 成功: {result:"success", url:..., thumb:...};失败: {result:"failed", message:...} 或 code!=200
|
||||||
@@ -357,8 +357,7 @@ function lskyCurlJson($method, $url, $payload = null, $token = null, $isMultipar
|
|||||||
$errno = curl_errno($ch);
|
$errno = curl_errno($ch);
|
||||||
$err = curl_error($ch);
|
$err = curl_error($ch);
|
||||||
$status = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
$status = (int)curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
||||||
curl_close($ch);
|
// 15m44w 续5c:删 curl_close(PHP8.5 deprecation 污染响应体)
|
||||||
|
|
||||||
if ($errno) {
|
if ($errno) {
|
||||||
return ['ok' => false, 'status' => 0, 'msg' => 'cURL错误: ' . $err, 'data' => null];
|
return ['ok' => false, 'status' => 0, 'msg' => 'cURL错误: ' . $err, 'data' => null];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user