date/time 对整个 wiki 的最后一次编辑

date/time of last edit to entire wiki

如何找到我整个 wiki 的最后一次编辑的 date/time?我想将此 date/time 写入文本文件,然后使用 ExternalData 扩展将其作为信息显示在我的维基页面之一 上。

谢谢, 拉斯

注意 1:我在编辑后收到(使用 ExternalData 2.3)错误消息 LocalSettings.php

注意 2:我在 upgrading 到 ExternalData 3.0

之后收到的错误消息

注3:将{{#get_external_data:替换为{{#get_db_data:后我得到这个结果(使用 2.3 或 3.0):

注4:相关行来自LocalSettings.php

$wgScriptPath = "/mediawiki-1.35.1";
$wgServer = WebRequest::detectServer();

## Database settings
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBname = "mywikidbname";
$wgDBuser = "mywikidbuser";
$wgDBpassword = "*********";

# MySQL specific settings
$wgDBprefix = "";

# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";

$wgShellLocale = "C.UTF-8";

# Enabled extensions. Most of the extensions are enabled by adding
# wfLoadExtension( 'ExtensionName' );
# to LocalSettings.php. Check specific extension documentation for more details.
# The following extensions were automatically enabled:
wfLoadExtension( 'ConfirmEdit' );
wfLoadExtension( 'PdfHandler' );
wfLoadExtension( 'SpamBlacklist' );
wfLoadExtension( 'TitleBlacklist' );
#wfLoadExtension( 'VisualEditor' );
wfLoadExtension( 'WikiEditor' );
wfLoadExtension( 'MathJax' );
wfLoadExtension( 'ImageMap' );
wfLoadExtension( 'Quiz' );
wfLoadExtension( 'TextScroller' );

wfLoadExtension( 'ExternalData' );
$edgCacheExpireTime=10;
$edgFilePath['inject'] = '/home/rwp/shares/share_wiki/rwp_external_data.txt';

$wgExternalDataSources['MW DB'] = [
    'type'      => 'mysql',
    'server'    => $wgDBserver,
    'user'      => $wgDBuser,
    'password'  => $wgDBpassword,
    'name'      => $wgDBname,
    'prepared'  => [
        'last revision' => 'SELECT rev_timestamp AS last FROM revision ORDER BY rev_timestamp DESC LIMIT 1;'
    ]
];

使用External Data,您可以在没有文件的情况下插入上次修订的时间。添加到 LocalSettings.php:

$wgExternalDataSources['MW DB'] = [
    'type'      => 'mysql',
    'server'    => $wgDBserver,
    'user'      => $wgDBuser,
    'password'  => $wgDBpassword,
    'name'      => $wgDBname,
    'prepared'  => [
        'last revision' => 'SELECT MAX(rev_timestamp) AS last FROM revision;'
    ]
];

然后用{{#get_external_data: db = MW DB | query = last revision | data = last = last}}{{#time: r | {{#external_value: last}} }} 得到需要的时间。

如果要使用文件,请使用以下 bash 脚本创建它:

mysql -h ($wgDBserver) -u ($wgDBuser) -p($wgDBpassword) ($wgDBname) -e "SELECT MAX(rev_timestamp) AS last FROM revision;" > last_revision.txt