- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Now that is taking the fail fast philosophy to another level. Call this fail frist.
Edit Admin
That sounds like the most PHP thing ever
Admin
Where's the "TODO: add real implementation" comment? (Bonus points if that comment was added 5+ years ago. )
Edit Admin
Okay, what type of database API is this where you can just read the PHP code? Normally you'll make a C/C++ wrapper whose sole purpose is to create functions you can call from PHP.
The only excuse I could give is the real backend API doesn't support locking directly (Connection library doesn't have a function for it, or it was added after the PHP extension was made), and you need to write the locking code yourself in raw SQL. If this is the case, that would explain things a little, and the dev who wrote the function didn't look up the SQL code yet.
Edit Admin
Maybe the particular database does not support any type of locking. The procedure would then be correct. The database would be a much bigger WTF though.
Edit Admin
The rest of you see a problem. All I see is a great timesaver: no need to spend hours trying to understand obfuscated code or test anything.
Admin
Didn't we have a story last week where the code contained the comment "ran out of budget?" Did the same thing happen here?
Edit Admin
I think you're right.
But from where I am, this is a clumsy way of doing it.
I understand that this is some multi DB API written in PHP. While I don't know what can and cannot be done in PHP per se, I would probably have tried to 1) add some way to query the API for what functionality it supports and 2) thrown an exception in this method. (1 would help any higher level methods in the API from running into exceptions...)
Because, as the OP indicates, they now had to spend time figuring out what was going on when the implementer could have given them that info up front. But maybe exceptions works differently in PHP... I'm willing to bet they do... (So maybe TRWTF is PHP? ;o)
Edit Admin
No budget was procured to begin with.