What's a recent frustrating bug you've had with a crazy simple solution?
JSn1nj4 Jun 19
Today I spent 1.5 - 2 hours trying to debug an issue I was having with PHPMailer -- or was it my
foreach loop, or perhaps a misspelled variable, or maybe that method name was supposed to start with a capital letter...?
Just kidding. The issue is fixed at this point, and I did at least learn something new today.
But I'm sure that cycle of questions is familiar to you. Questions like those seem to always clot together in the mind when something that is broken obviously shouldn't be -- or should it be? At that moment, who knows?
Today's problem -- I thought -- was caused by switching from PHP 5.3.x to 5.6.x for a specific codebase (see edit below).
What ended up being the culprit was the lack of the keyword
global at the top of a function that was using global variables. These variables (two of them, it turned out) were not being set within the function.
Lessons learned today
Don't automatically trust your own code. Even if it worked semi-recently, "semi-recently" isn't "now".
Look into language upgrades more often. Rare issues that occur between language versions do still happen, even if they are rare. Since not all projects use the exact same sets of features, looking for possible breaking changes between versions is definitely important.
Lingering confusion is probably worth looking into. After typing all of this, and knowing that the variables suddenly weren't accessible anymore - and looking into it for a little longer -- I'm still not 100% sure that the language upgrade is what caused this issue; it seems that the
globalkeyword was available back in PHP 4 (maybe someone with more experience knows).
Back to the question:
What have you been stuck on for some time that turned out to be unbelievably simply to fix?
P.S. I realize an upgrade from 5.3.x to 5.6.x is fairly "behind the times", but it happens to be where we are on a VPS we use. I do see that changing in the foreseeable future though.
Also, I apologize if my writing is all over the place. While I do look forward to being able to write more, this was only meant to be a quick little post anyway (and it may have even grown beyond that 😅).
Thanks for stopping by to read!
Edit: regarding #3 above, I'm definitely more confused now... A local dev who's used PHP since 5.2 told me without the
global keyword, it will always error out.