Tuesday, June 23, 2009

Rant: Stupid Debugging Day!

This is not going to be a tech recipe or anything productive. In fact, it's more of a kick myself in the arse type-of-deal. --and I guess also a reminder to myself if/when I have to make this change again.

Anyhow, here's the story in a nutshell: my project manager tasks me to roll out my code for our next version release to our test group. All goes well EXCEPT for one (yes, that's right 1) site. Odd. So, now I suppose it must be some rare issue with corrupt data in the database. I make a dump of the production db for that site and bring it down to beta to test. I run it through the upgrade; success! Interesting.

So now, I'm back again to try this upgrade again in production. Yup, fails again. Crap! So some fresh eyes need to take a look things over so I ask my manager to take a look. The issue puzzles him for a little bit, but then he IMs, "hold. I think I know why." :seconds pass: "working now?" And yes it is!

An error in the apache log sheds some light to the situation. Apache is complaining that an .htm file is missing in the root directory of my app. Apparently, this one site I needed to upgrade happened to be the first site in the apache conf and it didn't have this one file that the Netscaler needed. Awesome. Had nothing to do with my code. Spent pretty much the entire day debugging code to see what was going on. Lame...

At least now I know for future reference.

Cheers!

Friday, June 5, 2009

Update: WordPress - Modifying Post Content

Earlier in May I wrote up this post about modifying WordPress post content and prefixing URIs to go through a tracker. Well, one of the web designers here found this ridiculously rare bug. Apparently if you have content that has a URI that breaks at the end of a line because of word wrap, the trackURL function will not process. Weird!

So, I tested and confirmed and basically rewrote the entire function to one line. Who knew?

Anyhow here it is in all of its glory:

function trackURL($content) {
$content = preg_replace('/\< a(\s|\n|[^href])href=\"([^"]+)\"\>([^<]+)\<\/a\>/','$3',$content);
return $content;
}


Blogger is giving me gripe about the regex, so here's a screenshot:


Cheers!