Tag Archives: MediaWiki

Disable anonymous edits in MediaWiki

Using a MediaWiki installation to document internal systems where i’m currently at, and although we all have users it’s easy to forget to login before making edits. This results in a history full of IP addresses rather than names, which is a bit less useful. So, to prevent us from forgetting to login we decided to force ourselves to log in by disabling anonymous edits. You do that by adding the following to your LocalSettings.php.

$wgGroupPermissions['*']['edit'] = false;

Allow tel: protocol hyperlinks in MediaWiki

In MediaWiki you can already make email hyperlinks ([mailto:someone@example.com Mail someone]), but telephone number hyperlinks aren’t allowed for some reason by default ([tel:0123456789 Call someone]). Turns out to be an easy fix though.

Simply add the following to LocalSettings.php.

array_push($wgUrlProtocols, 'tel:');

Make it prettier

The links will get same icon as external links, which is a bit annoying, but that can be fixed as well. Find the main CSS file for your theme, in our case /skins/monobook/main.css, and look for a section which looks like the following.

#bodyContent a.external[href^="mailto:"], .link-mailto {
    background: url("mail_icon.gif") no-repeat scroll right center transparent;
    padding: 0 18px;

Simply make a copy of that section and replace all instances of ‘mailto’ with ‘tel’ and set the URL to the icon you want. The icon should of course be uploaded to the same location as the CSS for that to work 🙂

Promoting a user to sysop when all sysops are gone on a MediaWiki installation

Working for a client who has documentation on a MediaWiki installation which was set up before we got there. Was able to create users for ourselves through the regular site, but certain things like deleting pages can only be done by sysops. None of our newly registered users are of course sysops and the only existing sysop user is from whoever installed the wiki to begin with.

Here’s how to promote a user to sysop the hackish way, directly in the database.

Find database details

Note: This can of course be skipped if you already know how to access your mediawiki database, but I didn’t 🙂
  1. SSH into the system where MediaWiki is installed and find its location.
    Was /var/www/html/foowiki in our case.

  2. Open LocalSettings.php and everything should be under the heading ## Database settings

Promote user

  1. Connect with a mysql client.
    mysql -h localhost -u wikiuser -p wikidb
  2. Find the user id.
    SELECT user_id, CONVERT(user_name USING utf8) FROM `user`;
  3. Add user id to sysop (and bureaucrat) group.
    INSERT INTO `user_groups` VALUES (uid, 'sysop'),(uid, 'bureaucrat');

The user should now be sysop, which can be double checked on the Special:ListUsers wiki page.