If you hit this site or RSS feed today at the wrong time, you may have gotten strange or broken results… this is because of some little stupid thing that I was working on today.  I wanted to have my random face image that you see in the upper right show up in the RSS too because that is how many people read the site.  So I got a rss feed plugin “better feeds” that allows you to customize the way the RSS feeds work, and then I hacked it up to include my random face image.  After a couple of aborted attempts, I finally got it working, but for some reason some of the Wordpress administration tools completely stopped working.

Baffled, I reverted themes but found the same error present, and I struggled for a long time trying to figure out what the heck was going on.  Eventually after ruling out lots of other things, I disabled the plugins and found out that the problem was caused my inclusion of the “better feeds” plugin — but I still didn’t know why that should have anything to do with the problem.  So i did a bit of reseach, and I found out that the PHP include function which I was using to share code between the RSS feed and the sidebar, brings all of the variables from the included file into the current scope.  That is to say, all of the variable are completely global.

So one of the variables I used in my face rotation script conflicted with a variable name that the wordpress administration system uses, so when they overlapped it would prevent the administration from working problem.   When I finally moved all of the variable names to be specific to my little script, the administration interface instantly starting working again.  What I find most amazing is that not only is this behaviour not considered a bug, it’s seems to be an intentional feature of the wordpress, and indeed is the foundation of how the plugin system works.

This strikes me as a very terrible solution — to rely and use globals all over the place is just asking for trouble, trouble of the sort that I accidentally ran into.  I’ve seen plugin solutions implemented elsewhere and I suppose I just assumed that having hooks in important places and making that available to plugin authors was the way everyone did plugins.  But I’m not really impressed by the utter lack of controls wordpress seems to implement.  Oh well, it still works well as a blogging system…

In other meta news, I added a “how awesome is this post?” rating system to each entry, so please (ab)use this as you see fit.