MediaWiki is really no straightforward software for extension writers. Even if you think it is straightforward it is particularly not. So as an advice: if it looks just too easy to do … think twice!

As Timmy wrote in his blog I just ended an unpleasant dance with Mediawiki.

I had written a small extension for the spottingworld wikis that would copy page templates to new users’ pages as a welcome message. I was happy to see that there was the mentioned AddNewAccount hook available to get a wedge into the registration process. And it was really easy enough to use the hook, by copying the broad scheme from the Newuserlog extension.

But I had underestimated the pitfalls. And sometimes it’s really the minute details that are the deepest pitfalls. I had not put in a return true; statement at the end of my hook handling function. And as a result the Newuserlog extension was not called anymore.

It was easy enough to fix, but it makes me wonder what the sense is behind this statement. As part of the registration process it would be useful if an extension could veto a registration by simply returning false. But this did not happen. All our registrations went fine. All my mistake did was to not call other extensions using the same hook. I don’t see the reasoning of this except to annoy fellow developers.

2 Responses to “Captain Hook – or the pitfalls of AddNewAccount”

  1. NickJ says:

    This has been fixed now in the latest tree, as of one day ago. It will now generate a warning if an extension does not return something, which should in the future prevent the problem you described with other extension calls being clobbered. Thread about this is here: http://www.nabble.com/forum/ViewPost.jtp?post=11224995&framed=y
    – All the best, Nick.

  2. hook function says:

    [...] technology. DIY projects describing how to build electronic projects. Fun top 5 and top 10 lists.SpottingWorld Development Blog Archive Captain Hook – or …I was happy to see that there was the mentioned AddNewAccount hook available to get a wedge into the [...]

Leave a Reply