• Pinkie Pie (unregistered)

    lol omigosh frist!!11!!

  • KattMan (cs)

    So realyl, it doesn't matter if you are logged in. The || essentially makign it so if you are logged in you can upload, if you are not logged in, you can upload, because in our reality 2+2 does equal 4. Why not do away with the check in it's entirety? You will get the same results.

    EDIT: Just thought of a reason for this. It is to prevent anyone using one of those really old pentium processors where 2 might become a float and the math error might make 2+2 != 4.

    {shoots pinkie pie with caffine to watch her spontaneously explode}

  • Pablo Lerner (unregistered)

    I forgot my password, would you clear it?

  • jim (unregistered) in reply to KattMan
    KattMan:
    So realyl, it doesn't matter if you are logged in. The || essentially makign it so if you are logged in you can upload, if you are not logged in, you can upload, because in our reality 2+2 does equal 4. Why not do away with the check in it's entirety? You will get the same results.

    You don't say.

  • emaN ruoY (unregistered)

    if frist { postcomment("Frist!!>!@!@12!!"); } else { postcomment("Frist!!>!@!@12!!"); }

  • Fake Nagesh (unregistered)

    In abadabad code throws you

  • Qpirate (unregistered)

    I'm just looking at the WTF in the text: I started sifting throw hundreds Should it not be I started sifting through hundreds

  • Medinoc (cs)

    Looks like an "always true" clause added in the condition to force the behavior, probably temporarily for debugging purposes.

    TRWTF is the lack of comment/TODO/etc. about it and the fact it was checked in.

  • Melnorme (cs)

    Big Brother had decreed that your conditional expression not evaluate to true. Can computers doublethink?

  • Anketam (cs)

    normally if you want to force a true you add "|| true" not a math function. Reminds me of the shirt: 2+2=5 For extremely large values of 2

  • dkf (cs) in reply to Medinoc
    Medinoc:
    Looks like an "always true" clause added in the condition to force the behavior, probably temporarily for debugging purposes.

    TRWTF is the lack of comment/TODO/etc. about it and the fact it was checked in.

    Maybe the original author saw the technique in the log of some generated SQL and thought to himself “Neat! I'll try that myself…”

  • The_Assimilator (cs) in reply to Qpirate
    Qpirate:
    I'm just looking at the WTF in the text: I started sifting throw hundreds Should it not be I started sifting through hundreds

    You are correct. TDWTF needs to hire some proofreaders, stat.

  • Hello (unregistered) in reply to KattMan
    KattMan:
    So realyl, it doesn't matter if you are logged in. The || essentially makign it so if you are logged in you can upload, if you are not logged in, you can upload, because in our reality 2+2 does equal 4. Why not do away with the check in it's entirety? You will get the same results.

    EDIT: Just thought of a reason for this. It is to prevent anyone using one of those really old pentium processors where 2 might become a float and the math error might make 2+2 != 4.

    {shoots pinkie pie with caffine to watch her spontaneously explode}

    Thanks KattMan for the explanation! Couldn't have done it without you.

  • Rob Stark (unregistered)
    "I was recently assigned to work on a project that had been abandoned by its developer,"
    Since one out of 3 WTFs start this way (in real life, and, typically, here) shouldn't we just have a separate category for them?
  • Jason (unregistered)

    It's obviously debug code that either the original developer forgot to take out, or was purposely left in to bypass having to constantly log in. Since it was an unfinished project it's likely the latter and the new guy needs to get off his high horse. In my experience many developers when having to take over a new project will trash the work of the previous generation since it's easier to do than actually having to really learn the architecture.

  • RogL (unregistered)

    Could make sense as a temporary debugging change, to force the login to work while testing.

    A distinctive "true" value is easier to remove when testing is done.

    When it's time to remove the bypass, which would you rather search for: "true" or " || 2+2=4" ? You probably don't want to blindly remove all "true" strings but you can safely search&replace " || 2+2=4" with "".

  • Chester (unregistered)
    if ($this->ion_auto->logged_in() || 2+2==4)
    Easy. If you're coming from an alternate universe with slightly different physics, we need to know who you are. From this universe, welcome!
  • Chopper (unregistered) in reply to Anketam
    Anketam:
    normally if you want to force a true you add "|| true" not a math function. Reminds me of the shirt: 2+2=5 For extremely large values of 2

    Not if you're a banker!

  • Another fake Nagesh (unregistered)

    This remine me level of security here in Abadabad.

  • Jouva (unregistered) in reply to KattMan
    KattMan:
    So realyl, it doesn't matter if you are logged in. The || essentially makign it so if you are logged in you can upload, if you are not logged in, you can upload, because in our reality 2+2 does equal 4. Why not do away with the check in it's entirety? You will get the same results.

    EDIT: Just thought of a reason for this. It is to prevent anyone using one of those really old pentium processors where 2 might become a float and the math error might make 2+2 != 4.

    {shoots pinkie pie with caffine to watch her spontaneously explode}

    Thanks so much for explaining this! As a programmer I would NEVER have understood programming language logic and feel that such a joke obvious to the visitors of this website needed a full explanation.

  • ThingGuy McGuyThing (cs) in reply to RogL
    RogL:
    Could make sense as a temporary debugging change, to force the login to work while testing.

    A distinctive "true" value is easier to remove when testing is done.

    When it's time to remove the bypass, which would you rather search for: "true" or " || 2+2=4" ? You probably don't want to blindly remove all "true" strings but you can safely search&replace " || 2+2=4" with "".

    By golly, I think you've solved it.

  • Koko (unregistered)

    In my country we frist lern to spel and than we proveread.

  • Leo (unregistered)

    No good, because what if 2 changes so that 2+2 no longer equals 4? Should be "|| 2+2 == 2+2", so even if 2+2 = 6, it will still evaluate correctly.

  • BobB (cs)

    Cake or death?

  • Warlaan (unregistered)

    Seriously guys, that's like basic optimization knowledge.

    Yes, 2+2==4 is always true, but as it is an expression it is not for free. Now if logged_in() is true, 2+2==4 does not have to be evaluated at all, saving valueable processor time.

  • wbrianwhite (cs)

    It's clearly debug code. I on the other hand actually have "where 1 = 1" code in production. And I don't consider it a WTF. When appending various conditions to dynamic sql it's easier to start with a no-op condition and then append all the other conditions starting with "AND" without keeping track of "is this my first condition? no? then throw in and".

  • Nagesh (unregistered)

    This is obvious not C-based language. Sometime, developer is taking order-of-opeation for granted. Also, evaluation of OR is not treated seme in all language.

  • nonpartisan (cs) in reply to jim
    jim:
    KattMan:
    So realyl, it doesn't matter if you are logged in. The || essentially makign it so if you are logged in you can upload, if you are not logged in, you can upload, because in our reality 2+2 does equal 4. Why not do away with the check in it's entirety? You will get the same results.

    You don't say.

    I wish he hadn't.

  • KattMan (cs) in reply to Jouva
    Jouva:
    Thanks so much for explaining this! As a programmer I would NEVER have understood programming language logic and feel that such a joke obvious to the visitors of this website needed a full explanation.

    You are all welcome, I have fulfilled my public service for the year, thanks to all of you that listened.

  • Canonymous Oward (unregistered)

    Actually, the code might have a pretty legit reason. In some cases you can not just put "true" into "if" condition if there is "else" branch in the code, the compiler will complain about unreachable code.

    Seeing this in the production code kind of sucks though.

  • jonny_q (unregistered) in reply to Anketam
    Anketam:
    normally if you want to force a true you add "|| true" not a math function. Reminds me of the shirt: 2+2=5 For extremely large values of 2

    If 2+2==4 is his favorite debugging alias for "true" then it's easier to search for to remove later. It's a built-in todo.

    Still dumb, but that's the thought process.

    I've gotten very good as learning to think like the retard I have to clean up after.

  • AB (unregistered)

    Its a valid check that users from other dimensions, where Maths is fundamentally different, from accessing the upload functionality.

  • iToad (unregistered)
    // DEBUG
    % DEBUG
    REM DEBUG
    (* DEBUG *)
    /* DEBUG */
    ; DEBUG
    <!-- DEBUG -->
    # DEBUG
    ' DEBUG
    {- DEBUG -}
    etc...
    

    Using debug code? Pick one from the list above.

  • Quicksilver (unregistered) in reply to Chopper
    Chopper:
    Anketam:
    normally if you want to force a true you add "|| true" not a math function. Reminds me of the shirt: 2+2=5 For extremely large values of 2

    Not if you're a banker!

    Or you are living in Airstrip One!

  • Anon') or 1=1 (unregistered)

    The very first infinite loop I wrote when I was a noob looked like this:

    while(6 != 7)
    {
       ...
    }

    I thought I was so clever.

  • Weps (cs) in reply to Anon') or 1=1

    What's in logged_in() ?

    A throw perhaps?

  • Wintermute (unregistered)

    I've got it! If the program is being run in an alternate universe, then 2+2 might not equal 4. If this is a case, THEN we check to see if the user is logged in or not.

  • TheCPUWizard (cs)

    Actually it MAY matter... perhaps the latest version throws and exception in the if condition when the user is not logged int.

  • 1984 (unregistered)

    This is big brother protection.

    In case the government decides that 2 + 2 = 5, the code will actually require someone to be logged in.

  • Todd Lewis (unregistered) in reply to Weps
    Weps:
    What's in logged_in() ?

    A throw perhaps?

    Which is exactly what's wrong with the whole "try/catch let's pretend we've got objects in our made up computer world" style of programming.

    Now get off my nicely block structured lawn.

  • np (unregistered)

    Big Brother says 2 + 2 = 5.

  • np (unregistered) in reply to 1984
    1984:
    This is big brother protection.

    In case the government decides that 2 + 2 = 5, the code will actually require someone to be logged in.

    I had looked through briefly but missed your comment. Serves me right for making coffee instead of reading TDWTF. Glad someone else had a similar thought.

  • Nagesh (unregistered)

    #ifdef REQUIRES_LOGIN #define 4 5 #endif

  • Abso (unregistered) in reply to RogL
    RogL:
    Could make sense as a temporary debugging change, to force the login to work while testing.

    A distinctive "true" value is easier to remove when testing is done.

    When it's time to remove the bypass, which would you rather search for: "true" or " || 2+2=4" ? You probably don't want to blindly remove all "true" strings but you can safely search&replace " || 2+2=4" with "".

    " || debug_mode" would be even easier to search for.

  • jumentum (unregistered) in reply to Abso
    Abso:
    RogL:
    Could make sense as a temporary debugging change, to force the login to work while testing.

    A distinctive "true" value is easier to remove when testing is done.

    When it's time to remove the bypass, which would you rather search for: "true" or " || 2+2=4" ? You probably don't want to blindly remove all "true" strings but you can safely search&replace " || 2+2=4" with "".

    " || debug_mode" would be even easier to search for.

    • only morons commit debug code
  • KattMan (cs) in reply to Abso
    Abso:
    RogL:
    Could make sense as a temporary debugging change, to force the login to work while testing.

    A distinctive "true" value is easier to remove when testing is done.

    When it's time to remove the bypass, which would you rather search for: "true" or " || 2+2=4" ? You probably don't want to blindly remove all "true" strings but you can safely search&replace " || 2+2=4" with "".

    " || debug_mode" would be even easier to search for.

    not to mention pre compiler directives can make this a non issue. define it as true for debug builds, but false for production builds.

  • Anon (unregistered) in reply to The_Assimilator
    The_Assimilator:
    Qpirate:
    I'm just looking at the WTF in the text: I started sifting throw hundreds Should it not be I started sifting through hundreds

    You are correct. TDWTF needs to hire some proofreaders, stat.

    proughreaders, surely

  • fishdude (unregistered) in reply to wbrianwhite
    wbrianwhite:
    And I don't consider it a WTF. When appending various conditions to dynamic sql it's easier to start with a no-op condition and then append all the other conditions starting with "AND" without keeping track of "is this my first condition? no? then throw in and".

    Since you are dynamically building an SQL statement, I'll assume you are using PHP.

    Put all your WHERE clauses into an array, then use implode() to join the arrays into a string.

    $where[] = "param1 = 'fish'"; $where[] = "param2 = 'slap'"; $sql = "SELECT * FROM table WHERE " . implode(" AND ", $where);

  • Silfax (cs) in reply to Weps
    Weps:
    What's in logged_in() ?

    A throw perhaps?

    more likely a throw_up();

  • LD (unregistered) in reply to RogL
    RogL:
    Could make sense as a temporary debugging change, to force the login to work while testing.

    A distinctive "true" value is easier to remove when testing is done.

    When it's time to remove the bypass, which would you rather search for: "true" or " || 2+2=4" ? You probably don't want to blindly remove all "true" strings but you can safely search&replace " || 2+2=4" with "".

    Not only that, but there are quite a few compilers out there that won't allow you to write conditions that simply evaluates to either true or false, i.e. if(false) { ... }, because that produces unreachable branches. That includes things like if(expression || true) or if(expression && false) and things like that. The work around? ifdef (if there is a preprocessor); comment out the block; use conditionals (1==1, 2+2==4).

    By the way, there is no real reason you can't search for "|| true" because the only time you should have boolean literals is when you initialize a variable. "true" or "false" should never appear within a test.

    Just my $.02

Leave a comment on “Authenticate or Math”

Log In or post as a guest

Replying to comment #:

« Return to Article