CodeSOD: Constant Success
Dan was reviewing some PHP code written by a co-worker, as part of taking on a project. The code was in support" mode, rarely receiving changes, getting bug fixes only when absolutely necessary, and nobody really wanted to be the person responsible for it.
One of those not absolutely necessary" bugs was that sometimes, it just didn't save data. The user would enter a product listing, hit save, get a success message back, but the listing wouldn't actually be saved. No one had really dug into it, because having the end user do double data entry didn't bother anyone but the end user.
While thinking about that, Dan found this:
if ($query!=false) { $msg = 'This listing has successfully been saved!';} else { //$msg = 'There was an error saving the listing. Please try again later.'; $msg = 'This listing has successfully been saved!';}
At some point, someone complained about getting too many error messages when saving. So the previous developer fixed" this, by making sure that they never saw an error message again. This code had been in production for years.
[Advertisement] ProGet's got you covered with security and access controls on your NuGet feeds. Learn more.