Best Bug Ever

On behalf of a client of a client of SmartData, I was responsible this weekend for moving a website over from one server to another. It’s a monolithic old custom-written content management system, in Perl, which over the last four or five years has been passed from developer to developer and has begun to look quite disgusting. Needless to say, we’ll be recommending refactoring.

But in the meantime, a server move was needed. No problem, I thought. Install Apache on the new server, CGI::Application, mod_include, mod_rewrite, MySQL, blah blah, all pretty standard. Copy the files over, copy the database over, hook it all up, and test it. And after a day or two of playing with it on the new server and with approval from our client, we move the DNS over to complete the operation.

Yesterday morning I get a phone call from somebody who manages the site.

Romanian Days Of The Week“All of the days of the week are in French!”

I suppose I ought to say something about this particular company. Like many companies in this part of the world, this company runs it’s website bilingually: that is, in English and Welsh. But for some reason, claimed our client’s client, their web site was now putting the days of the week in French instead of Welsh. The months of the year were still in Welsh, and the stuff that was supposed to be in English was still in English, but… well…

Further investigation showed that this report was mistaken. “I’m not sure it’s French, you know,” I replied, typically helpfully, “It’s Romanian.” I was pleased with myself right up until the point that I realised that this wasn’t actually helpful, about a second or two later.

It turns out that the site uses a Perl module called Date::Calc to display days of the week in an appropriate language, and I’d just used CPAN to do a quick-and-easy install of Date::Calc. But something was different about the old server’s copy of this module. It turns out that, not unsurprisingly, Date::Calc doesn’t naively support the Welsh language, but that some time many years ago an enterprising programmer, not wanting to go to all the effort of adding a new language to Date::Calc the proper way, simply patched the module, overwriting one of the languages already in it. He decided to replace a language that he didn’t think anybody would ever have reason to use on the server – Romanian.

The reason that the months were still in Welsh was because they used a far more standard method of translation. So I simply wrote a couple of regular expressions that changed the old, Date::Calc-translator code into a more common approach, and that fixed it. Somebody had even already defined me an array with the Welsh weekdays in (it looks like this change was planned at some point in this huge, horrible codebase, but never actually happened).

Not sure I’ll ever find out who was responsible for the atrocious bit of coding that caused this particular website to turn Romanian for a few hours, but if I do, I’ll be sure to tell them about this, the most amusing bug I’ve seen in a long, long time.