简体   繁体   中英

Determining MediaWiki version from the database only

Ok, so. My MediaWiki migration from a server in the US to a server in Germany backfired, horribly, and I ended up with ONLY the database. The ENTIRE mediawiki installation was irrevocably lost.

I do NOT remember what version of MediaWiki the site was running, although it was semi-modern (sometime after January 2012).

The PostgreSQL database has been successfully restored in the new server.

Is there any SQL I can query to give me the version information? I have tried upgrading from 1.19 but it gives me all sorts of "columns already exist" errors and generally fails.

I recommends to simply upgrade to the latest version and not to worry about which version you had before.

MediaWiki should upgrade gracefully from any version (after 1.5) to the current. However, it is possible that this is not as smooth with PostGres as it is with MySQL, and it's also possible that some extensions don't do this well.

Please report any failures of the upgrade process to http://bugs.wikimedia.org .

EDIT : to answer the original question: the best way to find the MediaWiki version by looking at the database would be this query:

select max(ul_key) from updatelog where ul_key like 'updatelist-%';

YMMV , however. This is not an official or recommended version check. It looks at a table used for logging database updates, and gives you the latest version found in entries that start with "updatelist". These entries may go away, or change appreance. Also, I'm not sure PG supports the LIKE syntax I gave.

The best way to check your MediaWiki version is to look at Special:Version or, if the wiki isn't running, check $wgVersion in includes/DefaultSettings.php.

Unfortunately, it seems to not always be possible to get the (correct) version number out of the database. If you have access to backups of the php files, it is much easier and more reliable.

I have 2 Mediawiki installs, using PostgreSQL. One on an old Debian 8 Jessie, and one on a Debian recently upgraded to v. 10 Buster. In both cases querying just the database doesn't work. But "grepping" the Mediawiki php files does work right.

On the old Debian 8 with Mediawiki version 1.19

  • This gives the correct version:
$ egrep 'wgVersion|MW_VERSION' /var/lib/mediawiki/includes/{DefaultSettings,Defines}.php
/var/lib/mediawiki/includes/DefaultSettings.php:$wgVersion = '1.19.20+dfsg-2.3';
  • This still references an older version 1.15:
$ psql -U postgres -d wikidb -t -c "SELECT type, mw_version, sql_date, cdate FROM mediawiki.mediawiki_version"
 Update | 1.15.4     | $LastChangedDate: 2009-12-16 04:24:12 +1100 (Wed, 16 Dec 2009) $ | 2010-06-17 14:31:18.745713+02
  • And this has no such key in the table, so it returns nothing:
$ psql -U postgres -t -d wikidb -c "SELECT max(ul_key) FROM updatelog WHERE ul_key LIKE 'updatelist-%';"

On the Debian 10 machine with version 1.31:

  • This gives the correct version, on the last line of output:
$ egrep 'wgVersion|MW_VERSION' /var/lib/mediawiki/includes/{DefaultSettings,Defines}.php
/var/lib/mediawiki/includes/DefaultSettings.php: * @deprecated since 1.35; use the MW_VERSION constant instead
/var/lib/mediawiki/includes/DefaultSettings.php:$wgVersion = MW_VERSION;
/var/lib/mediawiki/includes/Defines.php: * This replaces the the $wgVersion global found in earlier versions.
/var/lib/mediawiki/includes/Defines.php:define( 'MW_VERSION', '1.31.10' );
  • This gives the same wrong old version as on the other machine:
$ psql -U postgres -d wikidb -t -c "SELECT type, mw_version, sql_date, cdate FROM mediawiki.mediawiki_version"
 Creation | 1.15.5-2squeeze5 | $LastChangedDate: 2009-03-20 12:15:41 +1100 (Fri, 20 Mar 2009) $ | 2013-05-11 11:57:22.946184+02
  • And the query suggested in brightbyte's answer , which should give the right result, for some reason doesn't on this machine. It gives the version 1.27, which was right before the upgrade:
$ psql -U postgres -t -d wikidb -c "SELECT max(ul_key) FROM updatelog WHERE ul_key LIKE 'updatelist-%';"
 updatelist-1.27.4-15461109030

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM