// 25.Oct.2009

Working Under the Hood


Photo Credit: Syntax Error - Folded Up Beyond All Recognition by Simon Pow

Oh the weather outside is frightful
By my Mac it's so delightful
Sign on to my WordPress node
Hack the code, hack the code, hack the code


Er, sorry about that folks (and Mr. Brooks). So I've spent my weekend fooling around with WordPress plug-ins and enjoying some hard-core coding action with a hot PHP interpreter. The results of which, are a handful of new features on this site, a few little things that should make your stay here even more rewarding than it already is (I know, I know – that hardly seems possible – but I've managed it, superstar hacker that I am.)

The first teeny-weeny change was transitioning this site from PHP4 to PHP5, because I'd heard that that was something that I should probably do – you know, when I'd got five minutes or so. This site is hosted by Media Temple and they've made it ridiculously easy to switch to PHP5. All I had to do was to add a line to my .htaccess file and the migration was immediate:

AddHandler php5-script .php

That wasn't hard was it? Note though that this method is probably host-specific and might not work with your provider.

Anyway, after a quick check through most of the site, I decided that everything was okay with the upgrade. I was delighted to note that WordPress' timezone functionality was enabled with PHP5 – just in time too since, as you probably know, we finished with British Summer Time in the small hours of the morning and switched back to regular GMT. This is an event that I have missed on three separate occasions now — from a WordPress standpoint — so I was delighted when the CMS automagically transitioned through the change.

As it happens though, there were a couple of failures on the site following the move to PHP5. The first was that my contact form broke, completely. Thanks to Noah Slater for drawing my attention to that, otherwise it'd still be out of service now.

Something else that went the way of the dodo was the little "related posts" plugin I'd been running since the dawn of time. That was completely fubar. I checked out several substitutes and finally settled on YARPP – and it's pretty damn good! YARPP relationships are built programmatically as opposed to the manual process I was previously employing. Therefore you are guaranteed to see more relationships advertised now than before (promoted with the tagline, "you might also enjoy...")

What else have we got? Oh yeah, this is a biggie… you can now subscribe to comments again. Hoorah! I used to have this functionality, many moons ago, but I gave it the boot when I discovered that it broke my validation. However, 'twas one of those things that I knew I'd have to bring back in some form, so I donned my hood and robes and performed an ancient and almost entirely forgotten mystical ceremony and, by the light of a full moon, I summoned up the code fairies with a whispered incantation. They toiled day and night and have given us back the means to request a simple email whenever there are follow-up comments to a post that we have, ourselves, commented upon. Do you guys appreciate the lengths that I will go to on your behalf? No, of course you don't. But I do it anyway because that's just the kind of guy I am.


Oh the WordPress search is useless
Primitive, slow and fruitless
Made the switch to an engine so extreme
Hey Lucene, hey Lucene, hey Lucene


Oh yeah, this is quite a biggie too, for both of you who've used this site's search engine. I've dumped the crappy built in search provided by WordPress because — how can I put this? — it's shite! I've worked tirelessly for at least five minutes to incorporate the peerless Lucene search engine into my humble little corner of the Web… and it totally rocks.

Aside from returning meaningful results to basic queries (which, let's be honest here, is the very least you'd expect) Lucene has a powerful (and fast) query parser that can interpret complex enquiries on our behalf. It also caches the results of common queries for a little bit of a performance boost. Woot!

All in all then, a quiet weekend. Yet surprisingly productive and educational. I'm going to go and chill out now, by climbing Mt. Everest or something. Adiós amigos.

Last Revision: October 25th, 2009 at 22:05


8 Comments for “Working Under the Hood”

  1. Firstly, I wonder what you have been eating.

    Secondly, I would like to check that the Lucene thing of which you speak is ‘Lucene Java’, cos Lucene seems to be a project what makes all kinds of different (well, mostly similar but you know) softwares. Powered by Java, so this little piggy can forget it, but I’m sure there are less scary alternatives.

  2. You don’t want to know what I’ve been eating Josh, my poor digestive tract is still recovering.

    The Lucene engine I’m working with is the Zend Framework version. Not quite as scary as Java. It doesn’t scale as well as the Java version, apparently, but the Urban Mainframe is hardly amazon.com is it? So it’ll probably be scalable enough for my needs and it beats the pants off the integrated search engine in WordPress.

  3. Yay, I got a mention!

    Why not just use Google search for your site? One less thing to worry about.

  4. @Noah: Yay, you did. I knew I had to work your name in there somehow. Thanks again for noticing my broken Contact page, I’d missed that completely.

    I could use Google search - but where’s the fun in that? Surely you’d agree that it’s much more challenging to work on your own stuff?

  5. I used to think like that, but after 6 years of trying to build my own publishing system, I realised that it’s just not worth the effort. Even when you do manage to build your own system, you end up spending all your time maintaining it.

    I realised that my time is better spent creating things that don’t continually need maintenance. i.e. writing, pictures, other stuff. You know, the stuff we’re trying to enable with all this busy work. A friend of mine said it much better than me:

    http://www.disobey.com/node/1822

    Read that and see what you think!

  6. That’s funny Noah, I was going to ask you how far you’d got with that publishing system.

    I agree with your sentiments. Hell, that’s why I dumped my home-brew CMS two years ago in favour of WordPress. That wasn’t an easy decision to make I can assure you. But, like yourself and the author of that article you linked to, I found that I was spending way too much time writing code, fixing bugs and worrying about matching the feature-sets of competing CMS’s. So much so, that I wasn’t actually producing any worthwhile content at all.

    So I discarded years and years of effort for an off-the-shelf CMS and I’ve never looked back (sort of, I still miss the exceptional performance I’d managed to achieve from my CMS - WordPress is way too slow for my liking).

    Having said all that, I am a coder first and foremost. I get my kicks from programming (that and my untamed crack habit) - so I’ll always “tinker” with this site. I’ll always write modules and plugins and try to add a little bit of gloss.

    The good thing is that WordPress has the sort of architecture that supports this. The core remains untouched. I just work with the APIs. That means that I break nothing and nothing is lost when I update WordPress. This, to me, is the best of all worlds.

    I’d hope you agree Noah, that I’m producing a larger volume and a higher quality of content than I ever did in my pre-WordPress days? If not, then I might as well give it up now.

  7. Sure, I would agree with all of that. However, I have found it a challenge in and of itself to try to remove as much technology as possible. Me and a friend have competitions to make the smallest possible programme that does a certain task. For example, he wrote an IRC bot in 23 lines of shell script. Hehe. So there’s always some fun to be had!

    http://inamidst.com/code/shellbot

  8. An IRC bot in 23 lines of shell script… you think that’s good eh? I once wrote an entire “Hello World” program in just one line of Perl!

    I get your point though, truly I do. But you’ll never stop me, not until you pry my keyboard from my cold, dead fingers.