Project:扩展维护
Parsoid
- 要使得Parsoid在LNMP 1.7环境安装包下顺利使用可视化编辑功能需要进行如下修改:
注释掉/usr/local/nginx/conf/enable-php.conf
中的#try_files $uri =404;
;- 注释掉
/usr/local/php/etc/php.ini
中的; cgi.fix_pathinfo=0
; - 与数据库无关,重启nginx和php-fpm即可。
Extension:CentralAuth
- 注意:以下方法仅在MW 1.19、1.23、1.27 测试成功,现在仅供参考。
使用共享数据库
- 简单使用共享数据库建立多Wiki,见下方。
- 关于多Wiki测试的总结:
- 最初目的是mediawikiwiki:Manual:Wiki family,但随后转变为mediawikiwiki:Manual:Wiki family(创建一个文件共享库)。
但遵循该章节文件库操作会出现“生成缩略图出错:无法找到文件”的错误提示,转而替代使用通用操作:mediawikiwiki:Manual:$wgForeignFileRepos。
同时对于mediawikiwiki:Extension:GlobalUsage的安装止步于第三项数据库更新操作。 - 初始目的是mediawikiwiki:Extension:CentralAuth,然而随后放弃研究这种高深莫测的安装文档,随之使用mediawikiwiki:Manual:Shared_database。
不过单纯这样进行操作时,所有的日志只会在所进行操作的wiki上留下记录。相关配置如下:
- 最初目的是mediawikiwiki:Manual:Wiki family,但随后转变为mediawikiwiki:Manual:Wiki family(创建一个文件共享库)。
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBname = "wiki_wiki"; # 所在的数据库
$wgDBuser = "wiki"; # 用户被授予对以wiki_开头的数据库进行操作权限
$wgDBpassword = "(hidden)";
$wgSharedDB = 'wiki_www'; # 所共享的数据库
$wgSharedPrefix = 'www_'; # 共享数据表前缀
# ↓必须勾选记住我的登录状态,否则打开另一个wiki后之前的账号自动退出
$wgCookieDomain = ".example.org";
# 默认开启表'user', 'user_properties'的共享(同一账号登录所有wiki)
$wgSharedTables[] = 'ipblocks'; # 共享封禁表(伪全域封禁)
$wgSharedTables[] = 'interwiki'; # 共享跨维基表
|
使用CentralAuth
- 使用CentralAuth建立多Wiki并启用SSO单点登录(基于Walkthrough归纳):
- 下载CentralAuth,拷贝至每个Wiki的扩展目录。
- 在LocalSettings.php中添加以下内容,并做相应修改。
# Database Settings
$wgMainCacheType = CACHE_DB;
$wgSharedDB = 'mw_foowiki';
$wgSharedTables = array( 'objectcache' );
require_once ("$IP/extensions/CentralAuth/CentralAuth.php"); //require the extension, pretty self-explanatory
# General CentralAuth configuration
$wgCentralAuthAutoNew = true;
$wgCentralAuthDatabase = 'mw_foowiki'; // default is 'centralauth'
$wgCentralAuthAutoMigrate = true;
#$wgCentralAuthCookieDomain = '';
# Create the local account on pageview, set false to require a local login to create it.
$wgCentralAuthCreateOnView = true;
# Skips the "login success" page
$wgCentralAuthSilentLogin = true;
# Deprecated, will be removed soon.
$wgCentralAuthUseOldAutoLogin = false;
$wgCentralAuthDryRun = false;
# unset( $wgGroupPermissions['*']['centralauth-merge'] );
# $wgGroupPermissions['sysop']['centralauth-merge'] = true;
// You can't just set wgConf values to the globals defined in Setup.php for your
// local wiki, because it hasn't run yet. You could hard-code $wgConf settings
// here, but instead we set the wgConf values in a hook that runs later.
$wgConf = new SiteConfiguration;
# Read wiki lists
$wgLocalDatabases = array( 'mw_foowiki', 'mw_barwiki', 'mw_quxwiki', 'mw_logwiki' ); //all wiki databases, as an array. Important to change.
$wgConf->wikis = $wgLocalDatabases;
$wgConf->suffixes = array(
'wiki'
); //We have the same suffix of wiki
//all databases have suffix wiki
$wgConf->suffixes = $wgLocalDatabases;
$wgConf->localVHosts = array( 'localhost' ); //your database server. could be example.com or IP address. no http://
$wgConf->siteParamsCallback = 'efGetSiteParams';
$wgConf->extractAllGlobals( $wgDBname );
$wgConf->settings = array(
'wgServer' => array(
'mw_foowiki' => '//www.example.org', //default means applied to all wikis. We want our location to be http://localhost/(wiki). If your wikis are hosted on different domains, then you would override this, but let's keep it simple
'mw_barwiki' => '//pool.example.org',
'mw_quxwiki' => '//test.example.org',
'mw_logwiki' => '//login.example.org',
),
'wgCanonicalServer' => array(
'mw_foowiki' => 'http://www.example.org', //default means applied to all wikis. We want our location to be http://localhost/(wiki). If your wikis are hosted on different domains, then you would override this, but let's keep it simple
'mw_barwiki' => 'http://pool.example.org',
'mw_quxwiki' => 'http://test.example.org',
'mw_logwiki' => 'http://login.example.org',
),
'wgScriptPath' => array(
'default' => '/', //script path, where index.php is located for meta
),
'wgArticlePath' => array(
'default' => '/index.php?title=$1', //for short urls
),
//IF IT'S NOT WORKING
//keep articlepath the same as scriptpath, with /$1 at the end. So for test_wiki it would be /testwiki and /testwiki/$1
'wgLanguageCode' => array( //dont change, if all wikis are english *BE careful not to alter this line if you use RegEx to replace COD with your wiki name!
'default' => '$lang',
),
'wgLocalInterwiki' => array(
'default' => '$lang',
),
);
function efGetSiteParams( $conf, $wiki ) {
$site = null;
$lang = null;
foreach( $conf->suffixes as $suffix ) {
if ( substr( $wiki, -strlen( $suffix ) ) == $suffix ) {
$site = $suffix;
$lang = substr( $wiki, 0, -strlen( $suffix ) );
break;
}
}
return array(
'suffix' => $site,
'lang' => $lang,
'params' => array(
'lang' => $lang,
'site' => $site,
'wiki' => $wiki,
),
'tags' => array(),
);
}
$wgCentralAuthCookies = true;
$wgCentralAuthCookieDomain = '.example.org';
$wgCentralAuthAutoLoginWikis = array(
'www.example.org' => 'mw_foowiki',
'pool.example.org' => 'mw_barwiki',
'test.example.org' => 'mw_quxwiki',
// 'login.example.org' => 'mw_logwiki',
);
# Activates the redirect to the "central login wiki"
$wgCentralAuthLoginWiki = 'mw_logwiki';
- 将扩展目录下的centralauth.sql导入中央Wiki所在的数据库,并执行以下语句:
- 将扩展目录下的centralauth.sql导入中央Wiki所在的数据库,并执行以下语句:
INSERT INTO global_group_permissions (ggp_group,ggp_permission) VALUES ('steward','globalgrouppermissions'),('steward','globalgroupmembership');
- 执行扩展目录中的
php migratePass0.php
、php migratePass1.php
、php migrateStewards.php
。
其中前两个命令也可以通过访问Special:MergeAccount完成。第三个命令需要先授予自己steward身份,然后在终端中运行,成功执行后该账户将变成全域steward。 - 若需要禁用行政员授予他人steward权限,以下为示例。
- 执行扩展目录中的
$wgGroupPermissions['bureaucrat']['userrights'] = false;
$wgAddGroups['bureaucrat'] = array( 'sysop', 'bot', 'bureaucrat', 'developer', 'observer', 'oversight', 'autopatroller' );
$wgRemoveGroups['bureaucrat'] = array( 'sysop', 'bot', 'bureaucrat', 'developer', 'observer', 'oversight', 'autopatroller' );
- 至此安装已经完成。
Extension:CheckUser
缺少useragent报错
注释掉/home/wwwroot/default/mw/extensions/CheckUser/src/TimelineRowFormatter.php
中的第99行//'userAgent' => $this->getUserAgent( $row->cuc_agent ),
(该行报错)后Special:Investigate中可以使用Timeline功能,但缺少useragent信息项。
- 猜想1:因为不是一开始就安装了Checkuser,所有有一部分信息出现了缺失(空值),而代码未对空置进行过滤而导致问题。
- 猜想2:若随MediaWiki一同安装可能不会出现此问题。
- 猜想3:应该只影响CheckUser安装前的用户。
- 结论: 对数据库中受影响的空值进行填充,可以得知: 历史记录是50项/页的,所以只要满足操作次数则可避免报错。
特殊页面Investigate
新的特殊页面带来了新的特性,当用户拥有investigate
权限后特殊页面会以Special:InvestigateBlock替代Special:Block页面。但原先页面依旧可用,只是隐藏了入口。现在的处理方式是分离该权限,仅在需要时使用。
详细说明可以参阅Blocking章节。
Extension:Display Title
DisplayTitle被用于显示与页面名称不一样的标题。根据扩展说明页面,在1.5.3
版本之后,所有与重定向相关的页面都会受到影响,例如:特殊:重定向页列表、特殊:链入页面、重定向的页面。
原有的页面名称将显示为重定向目标页面的名称,与用户的直觉不符。解决方案是安装低版本扩展。
Extension:PdfHandler
PDFHandler是一个MediaWiki安装时捆绑的一个扩展,理解的用途是在文章中展示PDF页面。但是现代浏览器chrome类和firefox列都能够打开网页上的PDF文件,似乎也不是怎么的重要了。一般来说,这个扩展未经配置是无法展现PDF页面的,取而代之的是一个Logo。
要让该扩展正常使用首先需要apt
安装which gs convert pdfinfo pdftotext
。
在LocalSettings.php中的配置如下:
1$wgFileExtensions[] = 'pdf';
2$wgUseImageMagick = true;
3wfLoadExtension( 'PdfHandler' );
4# Ubuntu
5$wgPdfProcessor = 'gs';
6// if defined via ImageMagick
7$wgPdfPostProcessor = $wgImageMagickConvertCommand;
8// if not defined via ImageMagick
9// $wgPdfPostProcessor = 'convert';
10$wgPdfInfo = 'pdfinfo';
11$wgPdftoText = 'pdftotext';
12# Debian
13$wgPdfProcessor = '/usr/bin/gs';
14// if defined via ImageMagick
15$wgPdfPostProcessor = $wgImageMagickConvertCommand;
16// if not defined via ImageMagick
17// $wgPdfPostProcessor = '/usr/bin/convert';
18$wgPdfInfo = '/usr/bin/pdfinfo';
19$wgPdftoText = '/usr/bin/pdftotext';
- 在迁移时发现
pdfinfo pdftotext
不安装亦可正常使用。
Extension:Semantic MediaWiki
在使用新版本Composer更新SMW时,Composer会提示报错 Package::setProvides must be called with a map of lowercased package name.
。目前找到的解决方法是使用旧版Composer(如版本2.1.14)进行更新。[1]如果遇到莫名其妙的包 冲突/丢失 的问题,可以尝试更换composer的源。
Extension:VisualEditor
- 此章节仅针对旧版VisualEditor,新版MediaWiki(1.35版本起)已内置相关组件无需额外安装。
- Extension:VisualEditor根据章节Linking with Parsoid in private wikis,添加了Installing on a private wiki中的内容,使其在本Wiki下可用。
- 本Wiki目前已使用Extension:NetworkAuth,对于来自Parsoid的访问进行自动登录,相关配置如下:
//弃用的配置
if ( $_SERVER['REMOTE_ADDR'] == 'SERVER-IP' ) {
$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['edit'] = true;
}
//启用的配置
require_once "$IP/extensions/NetworkAuth/NetworkAuth.php";
$wgNetworkAuthUsers[] = [
'iprange' => [ 'SERVER-IP',
'127.0.0.1' ],
'user' => 'Aria-bot',
];
- Parsoid服务的单服务器多站点的示例配置内容(位于
/etc/mediawiki/parsoid/config.yaml
)建议拷贝源代码:
worker_heartbeat_timeout: 300000
logging:
level: info
services:
- module: ../src/lib/index.js
entrypoint: apiServiceWorker
conf:
mwApis:
- # 1st
uri: 'http://www.kanade.win/api.php'
domain: 'www.kanade.win'
- # 2nd
uri: 'http://pool.kanade.win/api.php'
domain: 'pool.kanade.win'
- # 3rd
uri: 'http://test.kanade.win/api.php'
domain: 'test.kanade.win'
其他
语言
设置界面语言时,用户语言 要与 维基使用语言 保持一致;即便是相似的简体中文,其计算机编码也可能是不一样额。 目前这两个选项在配置文件中设置成一样的,也隐藏了前台的修改选项。