Attempted to run a customer's existing PHP application today, and when I visited the index.php, was greeted with a blank, white screen. I added in print statements, and turned on logging - and still, just a blank screen.
After much poking around, I finally narrowed down the cause of the broken app, as well as the silence to:
return @pg_pconnect("host=".$this->hostname.$port." ...);
Ahhh, the @ operator. Perhaps useful in some contexts, can be an absolute pain in others (dare, I say most). This operator suppresses errors from the function it prefixes. This is useful if you want deal with an error another way, than simply blurting out a message.
But what idiot puts the error suppression operator in front of the DB connection call, perhaps the most likely to fail call in the system, and the one you'd want to debug the fastest? I'm telling you, what was this programmer thinking?
(Whew, I feel better)
Back when I used to do code reviews, there were few things as egregious as swallowing exceptions. I had a whole 30 minute speech prepared for the programmer who made that slip-up. And once you got that speech, you wanted to do anything to avoid sitting through it again...
No comments:
Post a Comment