Thursday, March 27, 2014

The mysterious case of custom web framework

Few weeks ago I've come across one of the most annoying debugging sessions of all time. The task was to change few things and implement a custom PHP framework having the code provided. The project should have been live on Monday, and I've added new functionality on Friday, so I had plenty of time. On Monday morning I've uploaded the final version of the improved system with some more fast changes in the code.

But it didn't work. The most annoying after all, there were no error messages. I rarely get no error messages at all, even with xdebug turned on. No messages typically indicate a missing semicolon or an unneccessary opening curly bracket. But not in this case. Since everything worked by Friday, the error must be in the few lines I just added, so I started analyzing the new stuff.

I decomposed the new functions into smaller parts, smaller methods, essential fragments, as always. Finally I said, it must be dependency problem, something with the classes these new functions are built on. Debugging all classes took a lot of time, but still found nothing. Couldn't resurrect the code. It was Tuesday, deadline yesterday, what should I do... Continued debugging the parent classes of these, got rid of many unneccessary lines, but added way too much more.

By Thursday I had investigated and rewritten everything. Still no good result. Taking deep breaths, I started to look at the code again being pretty sure that the code is right. After a while it just popped up in my mind. The server ran ancient PHP 5.3, while the framework was using the shorthand array syntax first introduced in PHP 5.4.

No comments:

Post a Comment