无法保护 MediaWiki 中的翻译页面

Cannot protect a translated page in MediaWiki

我有一个 MediaWiki 站点。

在一页上,我有一个由 EmailForm 扩展实现的表单。

页面必须受到保护才能正常运行。我还需要将此页面翻译成捷克语。

所以我安装了 Language Extension Bundle 然后使用翻译扩展来标记要翻译的页面。

我也翻译了页面。原始页面有效,但捷克语翻译页面无效,因为它未受保护。

我试图保护 /cs 页面,但收到此错误消息:

You do not have permission to change protection levels for this page the following reasons:

- This page cannot be updated manually. This page is a translation of the page [Green Card Request] and the translation can be updated using the translation tool.
- You cannot change the protection levels of this page because you do not have permission to edit it.

我是站点管理员。

目前我已经禁用了实现保护要求的代码,但这不是一个好的长期解决方案。

/*
if ( !($wgTitle->isProtected ('edit')) )
    return ( EMAILFORM_NAME . " is only active on protected pages." );
*/

如果您确信所有已翻译的页面都可以安全地用作电子邮件表单,您可以将引用的代码更改为:

if ( !($wgTitle->isProtected('edit')) &&
     !(TranslatablePage::isTranslationPage($wgTitle)) ) {
    return ( EMAILFORM_NAME . " is only active on protected pages." );
}

当然,如果您不一定信任所有翻译页面的内容,那么事情就会变得更加复杂。基本上,您必须找出您 认为哪些页面足够安全,然后相应地修改检查。唉,我对 Translate 扩展还不是很熟悉,不知道它的权限模型是如何工作的,所以我不能在这里给出任何具体的建议。

(此外,当然,您每次升级 EmailForm 扩展时都需要重新应用此更改,但当前的临时修复也是如此。维护此类自定义的一种有用方法是保留一个 ( unified) diff of all the changes you've made, and reapply it with patch 每次升级后。如果你愿意,你也可以使用 git 维护 MediaWiki 的本地分支与你的自定义,并在新版本发布时合并来自上游的更改。)


最终,我怀疑处理此问题的正确方法是修复翻译扩展,让翻译目标页面以正常方式受到保护。 PageTranslationHooks::preventDirectEditing() 方法中有一个允许操作的白名单,但我怀疑它可能不像将 protect 添加到该列表那样简单,因为:

  1. IIRC,MediaWiki 本身很可能假设您必须能够编辑页面以保护它,并且

  2. 如果您确实设法保护了页面,这可能(或可能不会)在翻译扩展程序中触发一些奇怪的行为。

不过,应该可以通过某种方式解决这些问题。即使您不想自己尝试,您也可能想要 file a feature request(当然,假设有人还没有这样做)。