FAQ:MediaWiki
无法生成avg缩略图
如果要使用第三方的converter,参见Image thumbnailing页面
- 描述:
上传.svg
文件过后,页面中提示“生成缩略图出错:无法创建临时缩略图文件”,在“特殊页面:文件列表”中查看文件时:
Warning: symlink() has been disabled for security reasons in /www/wwwroot/wiki.eijux.com/includes/media/SvgHandler.php on line 280
。
- 处理:
默认安装的PHP一些函数是没有默认开启的。
我们需要的函数是symlink()
,则用在PHP的禁用函数中删除该函数即可。
- 描述:
生成缩略图处提示:sh: convert: command not found
,PHP错误信息为Warning: is_executable(): open_basedir restriction in effect. File(/bin/bash) is not within the allowed path(s): (/www/wwwroot/wiki.eijux.com/:/tmp/) in /www/wwwroot/wiki.eijux.com/includes/shell/Command.php on line 311
。
- 处理:
先考虑是PHP配置的问题,
PHP错误'''require(): open_basedir restriction in effect”''',即访问脚本不在'''<code>open_basedir</code>'''的限定目录里面,'''<code>open_basedir</code>'''的作用是将php所能打开的文件限制在指定的目录或文件。<br/>
修改PHP配置文件PHP.ini
的open_basedir
之后错误依旧,而后一直都盯着open_basedir
打转。兜兜转转许久才注意到sh: convert: command not found
的提示,想到可能没有配置Svg Converter,从而进一步发现MediaWiki没有默认安装Converter。最后在| 官网手册SVG节了解到支持信息,相关的Converter("ImageMagick", "ImagickExt", "sodipodi", "inkscape", "batik", "rsvg", and "imgserv")均需单独安装。相较之下,选用了| NativeSvgHandler扩展(将SVG文件直接发送至客户端以进行客户端渲染)。步骤如下:
- 下载文件,并将其放置在extensions/文件夹中的NativeSvgHandler目录内。(注意修改所有者及读写权限)
- 将下列代码放置在您的LocalSettings.php的底部:'
wfLoadExtension( 'NativeSvgHandler' );
' - 导航至Special:Version,以验证扩展已成功安装。
再于网页刷新,svg缩略图显示正常。
- 如果要使用第三方的converter,参见[https://www.mediawiki.org/wiki/Manual:Installing_third-party_tools#Image_thumbnailing Image thumbnailing页面]
左侧导航栏设置
MediaWiki的左侧导航栏,在搜索栏中搜索“mediawiki:Sidebar
”,
修改左侧导航栏如下:
* navigation ** mainpage|mainpage-description ** recentchanges-url|recentchanges ** randompage-url|randompage ** helppage|help-mediawiki * 标题 ** 链接 |名称 ** 链接 |名称 ** 链接 |名称
- Note:
- “*”后为标题,可以是MediaWiki命名空间的页面(如navigation,即“MediaWiki:Navigation”)、文本内容,不能为http链接或MediaWiki格式链接。(其后没有“**”内容则该标题不显示)
- “**”后为导航链接,可以是MediaWiki命名空间的页面(如mainpage,即“MediaWiki:Mainpage”)、http链接,不能为MediaWiki格式链接。
- 默认侧边栏只有两级(标题、链接|名称),若要实现多级链接、树形链接,需要需要修改MediaWiki的相关代码,或用Extension实现。
关于导航栏的SEARCH、TOOLBOX、LANGUAGES
我想要在左侧导航栏通过类似于模板的方式,来自定义导航页并添加到mediawiki:Sidebar中,类似于其中的TOOLBOX(SEARCH、LANGUAGES)导航栏,* TOOLBOX
,就可以变成:
工具 链入页面 相关更改 上传文件 特殊页面 页面信息
起初,我以为是需要在MediaWiki命名空间下安装Sidebar的规则编写文件就可以,但尝试一番以失败告终。
然后,我考虑是不是这些内容和skin有关,并在skins\Vector\includes\VectorTemplate.php
中看到了线索:
private function buildSidebar() : array {
$skin = $this->getSkin();
$portals = $skin->buildSidebar();
$props = [];
$languages = null;
// Render portals
foreach ( $portals as $name => $content ) {
if ( $content === false ) {
continue;
}
// Numeric strings gets an integer when set as key, cast back - T73639
$name = (string)$name;
switch ( $name ) {
case 'SEARCH':
break;
case 'TOOLBOX':
$portal = $this->getMenuData(
'tb', $content, self::MENU_TYPE_PORTAL
);
// Run deprecated hook.
// Use SidebarBeforeOutput instead.
ob_start();
Hooks::run( 'VectorAfterToolbox', [], '1.35' );
$props[] = $portal + [
'html-hook-vector-after-toolbox' => ob_get_clean(),
];
break;
case 'LANGUAGES':
$portal = $this->getMenuData(
'lang',
$content,
self::MENU_TYPE_PORTAL
);
// The language portal will be added provided either
// languages exist or there is a value in html-after-portal
// for example to show the add language wikidata link (T252800)
if ( count( $content ) || $portal['html-after-portal'] ) {
$languages = $portal;
}
break;
default:
// Historically some portals have been defined using HTML rather than arrays.
// Let's move away from that to a uniform definition.
if ( !is_array( $content ) ) {
$html = $content;
$content = [];
wfDeprecated(
"`content` field in portal $name must be array."
. "Previously it could be a string but this is no longer supported.",
'1.35.0'
);
} else {
$html = false;
}
$portal = $this->getMenuData(
$name, $content, self::MENU_TYPE_PORTAL
);
if ( $html ) {
$portal['html-items'] .= $html;
}
$props[] = $portal;
break;
}
}
$firstPortal = $props[0] ?? null;
if ( $firstPortal ) {
$firstPortal[ 'class' ] .= ' portal-first';
}
return [
'has-logo' => $this->isLegacy,
'html-logo-attributes' => Xml::expandAttributes(
Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) + [
'class' => 'mw-wiki-logo',
'href' => Skin::makeMainPageUrl(),
]
),
'array-portals-rest' => array_slice( $props, 1 ),
'data-portals-first' => $firstPortal,
'data-portals-languages' => $languages,
];
}
不懂PHP粗略看了下,自定义导航名称的话当前函数内并没有Hooks::run( 'VectorAfterToolbox', [], '1.35' );
类似的代码会执行,不知道函数返回之后的流程,就此搁置,以后再看吧。
【2020/09/09 00:40:57】
目录控制
当文章中含有3个以上标题时,mediawiki将自动在第一个标题之前生成目录(这是默认的设置)。
- 如果需要隐去目录,可以在文章中加入“
__NOTOC__
”标记; - 如果需要强制显示目录而不管标题数量,可以加入“
__TOC__
”标记; - 这两个wiki标记不限制出现位置,但一般出现在文章第一个标题之前。
open_basedir restriction in effect
- 描述:
错误信息为Warning: is_executable(): open_basedir restriction in effect. File(/bin/bash) is not within the allowed path(s): (/www/wwwroot/wiki.eijux.com/:/tmp/) in /www/wwwroot/wiki.eijux.com/includes/shell/Command.php on line 311
。
- 处理:
PHP错误require(): open_basedir restriction in effect”,即访问脚本不在open_basedir
的限定目录里面,open_basedir
的作用是将php所能打开的文件限制在指定的目录或文件。
查阅PHP配置文件php.ini
搜索open_basedir
如下:
; open_basedir, if set, limits all file operations to the defined directory ; and below. This directive makes most sense if used in a per-directory ; or per-virtualhost web server configuration file. ; Note: disables the realpath cache ; http://php.net/open-basedir ;open_basedir =
可知,当前未配置open_basedir
,添加配置如下:
open_basedir = /www/wwwroot/wiki.eijux.com/:/tmp/
- 注意
注意用open_basedir
指定的限制是路径前缀,而非目录名。所以如果要将访问限制在仅为指定的目录,应用斜线结束路径名。
如:若"open_basedir = /dir/user", 那么目录 "/dir/user" 和 "/dir/user1"都是可以访问的。
结果还是不好使
因为没有安装任何的svg渲染相关的扩展("ImageMagick", "ImagickExt", "sodipodi", "inkscape", "batik", "rsvg", and "imgserv".)