fix: 避免我的桌面读取空服务器信息
为服务器地址和软件标识逐字段提供非空兜底,避免模板在 PHP 8.5 下以 null 作为数组偏移量。
This commit is contained in:
1 parent
fb07c9bc7b
commit
ca4a5f4e4e
1 file changed
+7
-6
@@ -58,12 +58,13 @@ class Index extends AdminBase
|
||||
|
||||
$list['group'] = $admin->searchOne(session('user_id'))->groupnames;
|
||||
|
||||
$list['server'] = array_replace([
|
||||
// PHP's built-in server does not populate these Apache-specific
|
||||
// entries; provide portable values for the dashboard.
|
||||
'SERVER_ADDR' => request()->host(),
|
||||
'SERVER_SOFTWARE' => PHP_SAPI,
|
||||
], request()->server());
|
||||
$server = request()->server();
|
||||
$list['server'] = [
|
||||
// Some web servers expose these keys with null values. Keep the
|
||||
// template input non-null so it can safely access both entries.
|
||||
'SERVER_ADDR' => $server['SERVER_ADDR'] ?? request()->host(),
|
||||
'SERVER_SOFTWARE' => $server['SERVER_SOFTWARE'] ?? PHP_SAPI,
|
||||
];
|
||||
// 获取系统版本号
|
||||
$list->version = config('shangma.version');
|
||||
// 获取php版本号
|
||||
|
||||
Reference in new issue
Block a user