mediawikimediawiki-extensions

date/time of last edit to entire wiki


How can I find the date/time of the last edit to my entire wiki? I would like to write this date/time to a text file and then present it as info on one of my wiki pages as described here using the ExternalData extension.

thank you, russ

Note 1: Error message I'm getting (using ExternalData 2.3) after editing LocalSettings.php

enter image description here

Note 2: The error message I'm getting after upgrading to ExternalData 3.0

enter image description here

Note 3: After replacing {{#get_external_data: with {{#get_db_data: I get this result (using either 2.3 or 3.0):

enter image description here

Note 4: Relevant lines from 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;'
    ]
];

Solution

  • Using External Data, you can insert the time of the last revision to the wiki without a file. Add to 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;'
        ]
    ];
    

    Then get the required time with {{#get_external_data: db = MW DB | query = last revision | data = last = last}}{{#time: r | {{#external_value: last}} }} .

    If you want to use a file, create it with the following bash script:

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