Tragedy as body of teenage boy is pulled from river after 'entering with pals' as heatwave continues
Rita Ora FINALLY discusses THAT 'Becky with the good hair' cheating rumour
Cara Delevingne kisses girlfriend Minke and shows off their matching Alanis Morissette tattoos while at the side of the stage at rock star's Glasto gig
Cold-blooded steps Bryan Kohberger took to cover up the Idaho murders are revealed for the first time
What Prince Harry and Prince William could learn from Liam and Noel Gallagher as the Oasis frontmen gear up for their reunion tour
ChatGPT creates phisher’s paradise by recommending the wrong URLs for major companies
AI-powered chatbots often deliver incorrect information when asked to name the address for major companies’ websites, and threat intelligence business Netcraft thinks that creates an opportunity for criminals.…
CodeSOD: The Last Last Name
Sometimes, you see some code which is perfectly harmless, but illustrates an incredibly dangerous person behind them. The code isn't good, but it isn't bad in any meaningful way, but it was written by a cocaine addled Pomeranian behind the controls of a bulldozer: it's full of energy, doesn't know exactly what's going on, and at some point, it's going to hit something important.
Such is the code which Román sends us.
public static function registerUser($name, $lastName, $username, ...) { // 100% unmodified first lines, some comments removed $tsCreation = new DateTime(); $user = new User(); $name = $name; $lastname = $lastName; $username = $username; $user->setUsername($username); $user->setLastname($lastname); $user->setName($name); // And so on. }This creates a user object and populates its fields. It doesn't use a meaningful constructor, which is its own problem, but that's not why we're here. We're here because for some reason the developer behind this function assigns some of the parameters to themselves. Why? I don't know, but it's clearly the result of some underlying misunderstanding of how things work.
But the real landmine is the $lastname variable- which is an entirely new variable which has slightly different capitalization from $lastName.
And you've all heard this song many times, so sing along with the chorus: "this particular pattern shows up all through the codebase," complete with inconsistent capitalization.
.comment { border: none; }