余赚网 发表于 2026-4-25 09:31:06

Discuz! X 升级Discuz! X5.0 问题 New


卡在这里不知道什么原因



我知道答案 回答被采纳将会获得1 贡献 已有8人回答

小冰 发表于 2026-4-25 09:32:00

刷新 试试呢;进后台, 数据库校验 试试, 看 表结构 是否正常,

如果表结构正常 就说明是升级成功了

可可的可 发表于 2026-4-25 09:32:16

数据库校验 正常,前台显示错误

ysx24 发表于 2026-4-25 09:32:36

关闭插件,切换默认是否会出现

小冰 发表于 2026-4-25 09:33:01

所有插件都是关闭了的

::Bra 发表于 2026-4-25 09:33:28

龙龙 发表于 2026-4-5 17:17
数据库校验 正常,前台显示错误                        后台域名相关的配置重新配一下。
       

.ce-block {    margin-bottom: 20px;}.ce-block__content,.ce-toolbar__content {        /* max-width:calc(100% - 50px) */        margin-left: auto;    margin-right: auto;}.ce-paragraph {    line-height: 1.6em;    outline: none;    text-indent: 2em;    font-size: 16px;}.ce-paragraph--right {    text-align: right;}.ce-paragraph--center {    text-align: center;}.ce-paragraph--left {    text-align: left;}.ce-paragraph--justify {    text-align: justify;}.ce-paragraph-text-indent {    text-align: justify;}.ce-paragraph:empty::before{content: attr(data-placeholder);color: #707684;font-weight: normal;opacity: 0;}/** Show placeholder at the first paragraph if Editor is empty */.codex-editor--empty .ce-block:first-child .ce-paragraph:empty::before {opacity: 1;}.codex-editor--toolbox-opened .ce-block:first-child .ce-paragraph:empty::before,.codex-editor--empty .ce-block:first-child .ce-paragraph:empty:focus::before {opacity: 0;}.ce-paragraph p:first-of-type{    margin-top: 0;}.ce-paragraph p:last-of-type{    margin-bottom: 0;}.svg-icon {    width: 1em;    height: 1em;}.svg-icon path,.svg-icon polygon,.svg-icon rect {    fill: #4691f6;}.svg-icon circle {    stroke: #4691f6;    stroke-width: 1;}.inline-code {background: rgba(250, 239, 240, 0.78);color: #b44437;padding: 3px 4px;border-radius: 5px;margin: 0 1px;font-family: inherit;font-size: 0.86em;font-weight: 500;letter-spacing: 0.3px;}

月落秋水 发表于 2026-4-25 09:34:18

本地反复测试过多次,每次都出现这样的问题,数据库大概3G多,红色后宝塔面板显示数据有写入,写入几分钟后就没数据写入了。得不断多次刷新才会继续下去,但是这样刷新继续下次到升级成功数据出来都是错误的。

可可的可 发表于 2026-4-25 09:34:40

同样适用https://www.dismall.com/thread-27803-1-1.html

霸王别姬 发表于 2026-4-25 09:35:02

\source\function\cache\cache_setting.php

### 修复 1:第 77-99 行(profilegroup 配置处理)
修复前:

```
} elseif($setting['skey'] == 
'profilegroup') {
    $profile_settings = 
    table_common_member_profile_sett
    ing::t()->fetch_all_by_available
    (1);
    foreach($setting['svalue'] as 
    $key => $val) {
        $temp = [];
        if(!empty($val['field']) && 
        is_array($val['field'])) {
            foreach
            ($profile_settings as 
            $pval) {
                if(in_array($pval
                ['fieldid'], $val
                ['field'])) {
                    $temp[$pval
                    ['fieldid']] = 
                    $pval
                    ['fieldid'];
                }
            }
            foreach($val['field'] 
            as $fieldid) {
                if(!in_array
                ($fieldid, $temp)) {
                    $temp[$fieldid] 
                    = $fieldid;
                }
            }
        }
        $setting['svalue'][$key]
        ['field'] = $temp;
    }
    table_common_setting::t()
    ->update_setting
    ('profilegroup', $setting
    ['svalue']);
}
```
修复后:

```
} elseif($setting['skey'] == 
'profilegroup') {
    if(!is_array($setting
    ['svalue'])) {
        $setting['svalue'] = [];
    }
    $profile_settings = 
    table_common_member_profile_sett
    ing::t()->fetch_all_by_available
    (1);
    foreach($setting['svalue'] as 
    $key => $val) {
        $temp = [];
        if(!empty($val['field']) && 
        is_array($val['field'])) {
            foreach
            ($profile_settings as 
            $pval) {
                if(in_array($pval
                ['fieldid'], $val
                ['field'])) {
                    $temp[$pval
                    ['fieldid']] = 
                    $pval
                    ['fieldid'];
                }
            }
            foreach($val['field'] 
            as $fieldid) {
                if(!in_array
                ($fieldid, $temp)) {
                    $temp[$fieldid] 
                    = $fieldid;
                }
            }
        }
        $setting['svalue'][$key]
        ['field'] = $temp;
    }
    table_common_setting::t()
    ->update_setting
    ('profilegroup', $setting
    ['svalue']);
}
```
### 修复 2:第 865-878 行(plugins 配置处理)
修复前:

```
if(!$method) {
    $_G['setting']['plugins']
    ['available'] = $data['plugins']
    ['available'];
    if($adminmenu) {
        $adminmenu = array_merge(
            [['name' => 
            'plugins_system', 'sub' 
            => 1]],
            $adminmenu,
            [['name' => 
            'plugins_system', 'sub' 
            => 2]]
        );
    }
    savecache('adminmenu', 
    array_merge((array)$adminmenu
    , (array)$adminmenu));
}
```
修复后:

```
if(!$method) {
    if(!isset($_G['setting']
    ['plugins']) || !is_array($_G
    ['setting']['plugins'])) {
        $_G['setting']['plugins'] = 
        [];
    }
    $_G['setting']['plugins']
    ['available'] = $data['plugins']
    ['available'];
    if($adminmenu) {
        $adminmenu = array_merge(
            [['name' => 
            'plugins_system', 'sub' 
            => 1]],
            $adminmenu,
            [['name' => 
            'plugins_system', 'sub' 
            => 2]]
        );
    }
    savecache('adminmenu', 
    array_merge((array)$adminmenu
    , (array)$adminmenu));
}
```
### 修复原因
两处修复都是因为 PHP 8.0+ 对类型检查更严格,当变量是字符串而非数组时,访问数组偏移量会报错 "Cannot access offset of type string on string"。通过添加 is_array() 检查,确保变量是数组类型后再进行操作。

终于搞定升级了
页: [1]
查看完整版本: Discuz! X 升级Discuz! X5.0 问题 New