0

I have a LAMP environment with /var/www/html/x which is a MediaWiki website. I have a few more MediaWiki websites but I'd like to print the version of the x one to terminal.

I need to do so I could know what the last version was before I manually update MediaWiki.

Inside that dir, there's a file named RELEASE-NOTES-1.32 with the text:

== MediaWiki 1.32 ==

=== Changes since MediaWiki 1.32.0-rc.2 ===

MORE_TEXT...........

Maybe I should just print line 3 as with awk 'NR>3' /var/www/html/x/RELEASE-NOTES-* but maybe there's a better way to know the full version of a given MediaWiki installation.

What would be the best, most stable way to do this outputting?

2 Answers 2

1

If the wiki is up, the most robust method is to just ask (via the generator property of the siteinfo API, for example) - changes to that are subject to a deprecation policy, while any internal structure you rely on could change without warning.

If that's not an option, you can try parsing out the value of $wgVersion from includes/DefaultSettings.php. E.g.

ack '\$'"wgVersion\s*=\s*'([\w\d.-]+)';" --output='$1' mediawiki/includes/DefaultSettings.php

Checking the release notes works as well, if you always use proper releases, and only care about the major version.

0

You can run:

php maintenance/version.php
MediaWiki version: 1.35.6 LTS (built: 15:57, 1 August 2023)

And if maintenance/version.php doesn't exist you can add it:

wget https://raw.githubusercontent.com/wikimedia/mediawiki/master/maintenance/version.php -O maintenance/version.php
2
  • 1
    Doesn't that command simply get the version of the current MediaWiki version available on their repository? How would downloading that file help the OP know what version they actually have installed? Commented Aug 4, 2023 at 10:15
  • Sorry I wasn't clear. If you download the versions.php file to an existing install of MediaWiki that doesn't have the file (no need to download it if you already have it, older versions don't have this file) and then run it it will return the version of the code installed. Commented Aug 22, 2023 at 13:17

You must log in to answer this question.