You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mediawiki 1.39.8中MobileFrontend扩展兼容报错及版本冲突求助

问题描述

MediaWiki 1.39.8(PHP 7.4/8.0/8.1环境均测试)启用MobileFrontend扩展后出现500内部服务器错误,具体报错:

Fatal error: Declaration of MobileFormatter::parseItemsToRemove() must be compatible with HtmlFormatter\HtmlFormatter::parseItemsToRemove(): array in MobileFrontend/includes/MobileFormatter.php on line 67

LocalSettings.php相关配置:

wfLoadExtension( 'MobileFrontend' );
wfLoadSkin( 'MinervaNeue' );
$wgDefaultMobileSkin = 'minerva';

经排查核心矛盾为HtmlFormatter版本冲突:

  • 使用3.0.1版本:MobileFrontend功能正常,但TextExtracts/Popups预览功能失效,提示"There was an issue displaying this preview"
  • 使用4.0.3版本:TextExtracts/Popups功能正常,但MobileFrontend触发上述500错误

已提交官方Bug报告,以下是临时解决方案:

临时解决方案

方案1:修改MobileFormatter方法签名适配HtmlFormatter 4.0.3

打开MobileFrontend/includes/MobileFormatter.php文件,找到第67行的parseItemsToRemove方法,修改其返回值声明为: array,使签名与HtmlFormatter 4.0.3的父类方法一致:

protected function parseItemsToRemove(): array {
    // 原有方法内容保持不变
}

修改后,HtmlFormatter 4.0.3版本可同时兼容MobileFrontend和TextExtracts/Popups功能。

方案2:锁定兼容的扩展版本组合

根据MediaWiki 1.39.x的扩展兼容性,可尝试使用以下版本组合:

  • 测试HtmlFormatter 3.1.0版本(介于3.0.1和4.0.3之间),该版本可能同时兼容MobileFrontend和TextExtracts/Popups
  • 核对所有扩展版本与MediaWiki 1.39.8的官方兼容列表,确认版本匹配性

方案3:利用Composer管理依赖版本

如果使用Composer管理MediaWiki扩展,可在composer.json中指定兼容的版本约束,示例:

{
    "require": {
        "mediawiki/mobile-frontend": "~4.0",
        "mediawiki/html-formatter": "~3.1"
    }
}

执行composer update让Composer自动安装兼容的版本组合。

内容的提问来源于stack exchange,提问作者greektranslator

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 22:17:13