• Hanzito (unregistered)

    And then they abbreviate month to "M" in the function name, while spelling out "name to number" in full. That's got to be a frist.

  • (nodebb)

    Frist comment about the screwy comment. It says it "returns month name '01'", which is accidentally correct.

    Addendum 2025-01-16 06:39: Never mind, wrong on both counts. As I was going to originally say, the comment is just wrong.

  • Industrial Automation Engineer (unregistered)

    It's just a very sad "April's Fool" joke.

    I can't think of anything else.

  • Mick Moignard (unregistered)

    The copypasta machine also failed to change the parameter name to MnumberToMname as well as all the other failures in that function….

  • Greg (unregistered)

    the number to name conversion will not work for a very different reason: the name of the parameter passed into it is not the name they're using to check the month number. I don't remember if this triggers an undefined variable error in php or will simply return the input parameter in this particular case.

  • Zatapatique (unregistered)

    Maybe it's not in the original code, but MnumberToMname should have $mnum as the input parameter, but instead it's $mname.

    I also like the comment: //takes month number '01' and returns month name '01'

  • (nodebb)

    The real WTF is not using an IDE. Is there an IDE for PHP?

  • (nodebb) in reply to Rick

    Jetbrains PHPStorm.

  • Officer Johnny Holzkopf (unregistered)

    "Is it object-oriented or more procedural?" - "Yes."

  • (nodebb)

    Sometimes it feels like it is January forever in the north.

  • (nodebb)

    boy I sure hope they never have to run this in a non-English locale with different month names

  • Michael R (unregistered)

    oh boy, I would say they are in for some real octal pain.

  • Yazeran (unregistered) in reply to Michael R

    'octal pain' =~ s/o/re/; I presume you meant :)

    Yazeran

  • Michael R (unregistered) in reply to Yazeran

    No, I mean the 08 and 09 interpreted as octal with their leading 0.

  • (nodebb) in reply to sibtrag

    I thought September was the endless month?

  • (nodebb)

    I'll bet the broken function is never actually used. Even if they don't have unit tests, surely this bug could not have gone unnoticed.

  • (nodebb)

    Maybe they only test in January?

    Or maybe this is only used in one report that only runs in January?

  • Klimax (unregistered)

    Looks like they first wrote first version and then CP for the other way left job half finished...

  • (nodebb) in reply to Rick

    Is there an IDE for PHP?

    Sure, it's called vim and Notepad++.

  • (nodebb)

    The function comment sums it all up:

    function MnumberToMname($mname) //takes month number '01' and returns month name '01'

    That's all we need to know there's really bad code ahead. Whoever even writes this is clearly not paying attention.

  • (nodebb) in reply to Ralf

    Come on! Isn't everyone using MS Code nowadays?

  • (nodebb) in reply to Rick

    it's called 'rm'

  • (nodebb) in reply to Ross_Presser

    Depends on the context. I presume you're thinking of either https://en.wikipedia.org/wiki/Eternal_September or to folks referring to Mastodon (or possibly the Fediverse writ large) having its own starting in September 2022. But there's also https://ismarchoveryet.com and I'm sure there are others I don't know about.

    Addendum 2025-01-16 13:53: "or to folks" should have been "or of folks."

  • (nodebb)

    ... every now and then I have a bit of imposter syndrome, where I wonder if I'm actually a 'good enough' programmer ... then I see sh!t like this ...

  • löchlein deluxe (unregistered)

    I guess "writing the constant first in a comparison" is one of those "tell me you've learned the hard way without saying you've learned the hard way" things. (Or you could be Guido and have statements that aren't functions-that-return-void. (And yes I know there's := in Python now.))

  • Lion (unregistered) in reply to Rick

    Yeah, Intellij WebStorm should do that. No excuse for this shit.

  • (nodebb)

    Ref:

    I guess "writing the constant first in a comparison" is one of those "tell me you've learned the hard way without saying you've learned the hard way" things.

    Or it's simply a coding standard where you once worked. I still think it looks awkward, but I acknowledge it's a goof-reducer. And dev needs all the goof-reducing tactics it can muster.

  • Clive (unregistered) in reply to Greg

    It may work in PHP7 but will trigger a warning in PHP8, as they are usually set up.

  • erffrfez (unregistered) in reply to Greg

    so based on the comment, this is the part of this sample of code that does what it claims. We all know we can trust comments to be accurate....

  • erffrfez (unregistered) in reply to erffrfez

    or at least the "returns" part of the comment is accurate

  • erffrfez (unregistered) in reply to erffrfez

    a sort of wtf on this is that there are websites where comments are input and shown in separate display from the original page.. so to add a comment, one has to keep a bundle of detail in mind.

    why can't we just scroll up and down to either read all the comments while still seeing the page text, or add a comment while also still seeing that text or image?

  • markm (unregistered)

    There's no default in case none of the comparisons match. So in the first function (the only one that could ever work!) if someone misspelled the month name or used a non-English spelling (which should be errors, but there's no error handling), it could return either an empty string or any random string, depending on whether PHP initializes local variables or just picks up whatever data was in the location for $mnum.

    And the second function has multiple layers of failure. Correct the input parameter, and the first 'if' statement changes it to "01". Unless PHP is even weirder than 'c', this is after the comparison, so it never matches any input but "01", and the output is either "" or a random string. Then there's the foul-up for April. Finally, there's no error handling or default; an input of "1" instead of "01", won't match and won't indicate anything is wrong.

  • FTB (unregistered)

    I'm guessing "MnumberToMname" isn't actually used anywhere...

  • x (unregistered)

    Since there are no else branches, what happens with invalid function arguments? I guess I'm lucky for not knowing php.

  • (nodebb) in reply to erffrfez

    a sort of wtf on this is that there are websites where comments are input and shown in separate display from the original page.. so to add a comment, one has to keep a bundle of detail in mind

    Right click and then "Open Link in new tab" is your friend.

Leave a comment on “Halfway to a Date”

Log In or post as a guest

Replying to comment #:

« Return to Article