Pages

Sunday, August 23, 2009

Broken users

Special:BrokenRedirects is one of MediaWiki's most interesting - and, ironically enough, probably one of its most broken - special pages. It lists "broken" redirects - i.e. if the target doesn't exist but a page redirects there, the page is considered to be a broken redirect. What's interesting is that it considers interwiki redirects also "broken" in cases where interwiki redirecting isn't enabled.

But interwiki redirects are not broken redirects. The software has no (easy) way of checking - or if it does, it's not used - whether the page on the target wiki exists or not, so it just assumes that it's a broken redirect. This is probably why people use silly "soft redirect" templates.

Soft redirects are - at least in my opinion - pointless. Interwiki redirects are not broken redirects. If you, as an editor, cannot tell the difference between a redirect to a nonexistent page and a redirect to another wiki, then the only one who is broken is you. Not the software and most certainly not the redirect.

So why do I even care? Because:

  • soft redirects are pointless

  • I used to use interwiki redirects *a lot* during my time at Wikia and I absolutely hate getting notifications about new messages on some random wiki I haven't edited more than once



Seriously, just because you don't understand it doesn't mean that it's broken.

Saturday, August 15, 2009

The unanswered questions

Some time ago Wikia relaunched answers.wikia, their questions & answers site. It looked (and still looks) quite nice, so I was wondering how they did it. I looked into their SVN and found something related to the project. A skin, some extensions, some maintenance scripts...but one crucial thing was missing: a class called "Answers". The skin used functions provided by this missing class, which meant that the skin wouldn't work properly without the class.

What should I do? I decided to ask Wikia about the issue on their Q & A site. That's what it's for, right? The original answer to my question was quite vague. So I decided to reword my question a bit. This time I got a better answer: I was told to contact Wikia if I wanted to develop the source code (ah, Special:Contact, how much I love thee!).

Being the nice person I am, I sent in a polite request regarding the matter. I soon got a reply from a staff member who wrote that they'll be making sure that this report ends up to the right people. That was on May 21, 2009. I waited for over a month for something to happen regarding the matter, but nothng happened, so I decided to pay a visit to their IRC channel, #wikia. I was told that the IRC channel is not the place to get support (wtf?) and that the ticket -- my request -- has been forwarded to another person. The person I talked to refused to even tell who this "another person" in question is!

On August 9, 2009 I sent in another request through Special:Contact. The request was short and sweet: "rt#15912 needs some love." The ticket in question, rt#15912, is the one I sent back in May. This time I got a reply from a different staff member and they told me who this mysterious "another person" in question is. I'm supposed to discuss with this person about the source code of answers.wikia project.

But...why should I, really? There's nothing to discuss about, really. If Wikia is truly an open source project, then they should get a developer to commit those missing files. Typing "svn commit -m"adding missing files" file1.php file2.php fileN.php" in command line is not rocket science. Or then I'm a rocket scientist, as are my co-developers.

An anonymous user of answers.wikia (who, for the curious minds, isn't me) speculated that speculated that the delay in publishing the source code is intentional, in order to prevent competitors. I bet that if someone wanted to set up a competiting site, they'd just buy AnswerScript or something similar instead of using MediaWiki extensions and patches.

People should stop thinking open source as a threat and start thinking it as an opportunity.

Thursday, October 2, 2008

Code reviewing made easy

Services such as Google Code have offered code reviewing tools as a part of their service. Their code review tool is so great that even Wikia uses it. Nothing like that has ever been available for MediaWiki...until now.

CodeReview is a MediaWiki extension by Brion Vibber, Aaron Schulz, Alexandre Emsenhuber and Chad Horohoe that provides a code review tool for MediaWikis. You can see a live demo on MediaWiki.org. Privileged users can "tag" commits as "ok", "fixme" and so on and (by default) everyone can comment on commits. Sure, it isn't as fancy as Google Code's (yet anyway ;-), but it's nice to have a "native" solution rather than having to use Google's or some other provider's services. Currently CodeReview extension seems to be requiring at least MediaWiki 1.13 or 1.14alpha and didn't work for me under 1.13alpha.

If you find yourself emailing your fellow co-committers more than often and you just happen to operate a MediaWiki instance, maybe you'd want to check out this extension. Granted, CodeReview isn't perfect and there still are a couple things that the developers would like to see fixed. But trust me, it's quite good start for a code review tool for MediaWiki. I'd most certainly recommend trying it out if you have some moments, a MediaWiki and a SVN to spare.

Sunday, September 7, 2008

The wonders of PHP programming

I decided to update my working copy of regexBlock extension and finish up some work I started doing a long time ago - integrating changes from Wikia's SVN.

Everything looked nice until the update finished. I've got not only one but two files in conflicted state. I fix them and svn up again. Now I've got a clean-ish working copy and I can retry applying the Wikia modifications to my local copy.

One of the major annoyances of Wikia codebase is EasyTemplate class. The class supposedly allows "for easy mixing [of] HTML/JavaScript/CSS/PHP code". If you've ever written code for MediaWiki or taken a look at MediaWiki's source code, you're aware of public function addHTML in OutputPage.php. It does exactly what Wikia's EasyTemplate does, and even a bit easier IMO.

So the first thing I had to do to get the new regexBlock code working was to kill the EasyTemplate dependency. Thankfully that's about the easiest task there can be. Just replace the code referring to EasyTemplate with $wgOut->addHTML( 'code goes here' ); and that's almost about it (not quite, but let's not get into too technical details). Now I've got a working version of the extension in front of me, yay! Time to test it, so I'll add the extension into the LocalSettings.php of my local testing wiki, add the required tables to the database and go to the wiki to see any and all possible issues.

Okay, the special page loads, although the interface looked like as if there was at least one unclosed <div> tag. And then there was something other noteworthy too: one PHP notice (E_NOTICE) and one PHP warning (E_WARNING). The notice was about an "invalid argument supplied to foreach() on line..." and the warning was about an error within a function that used PHP's array_combine function. The warning related to array_combine function was actually very easy to fix, although I could've sworn that the first, obvious and correct fix didn't work the first time I tried it. After a while of trying, the error went away. That was the easy part of the upgrade...

What was remaining was the notice about an invalid argument to some foreach loop. It sounds relatively easy now, doesn't it? It certainly wasn't such. The current code (which does not raise any notices or errors) looks like this:


$selected = htmlspecialchars( ($k == $this->mRegexBlockedExpire) ) ? 'selected="selected"' : '';
foreach( $expiries as $k => $v ) {
$wgOut->addHTML('<option value="'.$selected.'">'.htmlspecialchars($v).'</option>');
}



But when I had moved the code to the main .php file from the template file, I had pretty much copy-pasted parts of the code and it looked like this:


foreach( $expiries as $k => $v ) {
$wgOut->addHTML('<option value="'.htmlspecialchars( ($k == $this->mRegexBlockedExpire) ) ? 'selected="selected"' : ''.'">'.htmlspecialchars($v).';</option>');
}



I do understand the people that hate PHP a bit better now. After I had fixed a couple errors like this, the interface worked relatively nicely.
Of course, I had to fix a couple message names - internationalization (i18n) support was added for regexBlock ages ago, but Wikia had added i18n on their own, which led to a new issue: a message containing some string, say, "permanent block" was called 'regexblock_permament_block' (sic) in Wikia's version and 'regexblock-view-block-infinite' in the official version.
Well, this was relatively easy task to be honest. After all, I only had to compare the two i18n files against each other and alter the message names in SpecialRegexBlock.php.

So, now what? Now I had a working, improved version of regexBlock extension that is error-free. Or that's what I thought myself. I tested the actual blocking mechanism and whoops:


Expiry time invalid.


No wonder that there are comments like "Fuck you, PHP. Fuck you in the ear!" around the MediaWiki codebase.

So, it's back to the drawing board for me, so to say. Maybe I'll have this extension upgrade finished before Christmas 2008, who knows.

Tuesday, September 2, 2008

New blog

It's been a while since I've had a blog. Rather, a long while. I've never really understood the secret of blogging and why so many people keep their own blogs...well, maybe things would change now.

Assuming you remember my old blog, I really didn't have the time or interest required in updating it. And I've always preferred MediaWiki. Granted, I'm a MediaWiki developer nowadays and thus it's kinda obvious why I'm so biased towards MediaWiki than anything else.

I've also enabled anonymous commenting on this blog. Nevertheless, I suppose that almost everyone has a Google account that they can use to comment. However, this is a privilege granted to you — please don't abuse it.

If you need to contact me privately, feel free to email me at jack@countervandalism.net. You're free to post MediaWiki-related questions on my MediaWiki.org user talk page. I'd strongly suggest asking on IRC & mediawiki-l / wikitech-l for help though, because many experienced developers and users monitor those.