fix: 修复微信支付证书open_basedir路径解析错误及PHP8.5兼容性问题

这个提交包含在:
2026-11-12 18:20:32 +08:00
父节点 4885dd3ba0
当前提交 ad73da1db4
共有 4 个文件被更改,包括 25 次插入 和 7 次删除

查看文件

@@ -69,7 +69,7 @@ class Api
* @access public
* @param Request $request Request 对象
*/
public function __construct(Request $request = null)
public function __construct(?Request $request = null)
{
$this->request = is_null($request) ? Request::instance() : $request;

查看文件

@@ -324,7 +324,7 @@ class PaymentService
* @param array|null $wxTxData 异步回调已解密的交易数据;传 null 时自动向微信网关主动查单
* @return array
*/
public static function confirmOrderPay($outTradeNo, array $wxTxData = null)
public static function confirmOrderPay($outTradeNo, ?array $wxTxData = null)
{
$outTradeNo = trim((string)$outTradeNo);
if ($outTradeNo === '') {
@@ -1122,7 +1122,7 @@ class PaymentService
* @param array|null $wxBillData 微信回调已解密报文;传 null 则主动调用微信查单接口
* @return array 最新提现单行记录
*/
public static function syncWithdrawTransfer($withdrawId, array $wxBillData = null)
public static function syncWithdrawTransfer($withdrawId, ?array $wxBillData = null)
{
$withdrawId = (int)$withdrawId;
$wd = Db::name('withdraw')->where('id', $withdrawId)->find();

查看文件

@@ -32,7 +32,7 @@ class WxPayException extends \RuntimeException
$curlErrno = 0,
$isUncertain = false,
$rawDetail = '',
\Throwable $previous = null
?\Throwable $previous = null
) {
parent::__construct((string)$message, (int)($httpCode ?: $curlErrno), $previous);
$this->wxCode = (string)$wxCode;

查看文件

@@ -1054,10 +1054,28 @@ class WxPayV3Service
if ($path === '') {
return '';
}
if (is_file($path)) {
$root = defined('ROOT_PATH') ? rtrim(ROOT_PATH, '/\\') : dirname(__DIR__, 3);
// 1. 若已经是项目根目录下的绝对路径
if (strpos($path, $root) === 0 && @is_file($path)) {
return $path;
}
$root = defined('ROOT_PATH') ? rtrim(ROOT_PATH, '/\\') : dirname(__DIR__, 3);
return $root . DIRECTORY_SEPARATOR . ltrim(str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path), DIRECTORY_SEPARATOR);
// 2. 拼接项目根目录后的候选绝对路径
$candidate = $root . DIRECTORY_SEPARATOR . ltrim(str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path), DIRECTORY_SEPARATOR);
if (@is_file($candidate)) {
return $candidate;
}
// 3. Windows 盘符绝对路径
if (preg_match('/^[a-zA-Z]:[\\\\\/]/', $path) && @is_file($path)) {
return $path;
}
// 4. 若以斜杠开头,避免触发 open_basedir 报错,优先返回 candidate
if (strpos($path, '/') === 0 || strpos($path, '\\') === 0) {
return $candidate;
}
// 5. 兜底检测
if (@is_file($path)) {
return $path;
}
return $candidate;
}
}