Thursday, August 27, 2015
Text Size

MediaWiki: MySQL to extract path to images

In not as many words as others, here's my MySQL query to extract details on images stored in the MediaWiki CMS system (v1.14).

Prior to a migration and just after another change freeze, I had sent all Wiki articles modified since the last export but then needed to send all images that had also been either added/modified since.

Using MySQL, the following query lists the image name, size, user who uploaded, timestamp and the path. Remember that the paths are determined using the MD5 Hash of the filename:

List MediaWiki Articles

What do I want?
Page ID, Title, Content, Category, AccessLevel (note that AccessLevel is extra to your standard MediaWiki setup and one that was customized for my day job).

Thought I already had this somewhere on my site, so it took a while again but I've posted my finished query here:

The base query to list mediawiki articles
Page ID, Title, Content, Category

  1.  SELECT 
  2.            p.page_id AS PageID, 
  3.            CONVERT(p.page_title USING latin1) AS PageTitle, 
  4.            CONVERT(t.old_text USING latin1) AS PageContent, 
  5.            (SELECT GROUP_CONCAT(CONVERT(wikimedia_categorylinks.cl_to USING latin1)) FROM wikimedia_categorylinks WHERE wikimedia_categorylinks.cl_from=p.page_id) AS PageCategory 
  6.       FROM 
  7.            wikimedia_page p 
  8.       LEFT JOIN wikimedia_revision r ON p.page_latest=r.rev_id 
  9.       LEFT JOIN wikimedia_text t ON r.rev_text_id=t.old_id 
  10.       WHERE 
  11.            p.page_namespace=0 
  12.            AND t.old_text='' 
  13.            AND p.page_is_redirect=0 

Change the login link in MediaWiki

As usual I have searched the WWW but I obviously don't how to use Google because I couldn't find an answer. My situation is this:
  • We have an internal wiki knowledge base using MediaWiki version 1.14.
  • Some articles are available for public, some are restricted to staff and different localgroups.
  • When users click on the 'Login' link, we want the system to automatically prompt them for their username/password. (Kerberos authenticated, as opposed to NTLM authenticated).
  • Note: This article is displaying how to change the link and not how to setup these authentication methods.

Comparing two mediawiki sites

In this particular case, I'm comparing my Live and Dev versions of the same MediaWiki site. I want to add the SQL queries I used to this article but I'm in the middle of carrying out this process and it's due in two hours.

    Checking both MediaWiki have the same article content:
  1. Print Special:AllPages from both sites and do an eye-check (I basically highlighted articles found in one but not the other - we had over 2000 articles... I guess I'm a bit geekly like that)
  2. This doesn't show modified date and content size differences but I can run this SQL query to show me these.

How to put MediaWiki into Debug mode

 By adding the following line to your LocalSettings.php file, you will be able to log everything that WikiMedia does:

$wgDebugLogFile = '/home/username/public_html/wikidir/logfile';

IMPORTANT NOTE: The path above should be the exact full path to the wiki directory under your account.

Help Develop!

Thank You! :c)

Connect: Google+

Visitors of the World

Latest Posts