Genuine production code...



  • This is an enterprise CMS, bought and paid for by the large educational establishment in England for which I work. Yes yes, TRWTF is php but I give you...

    // decide what to do
    switch($type) {
    	case 'class':
    	case 'include':
    	default:
    		return $hide;
    	break;
    }
    


  • Oh and this same piece of carp is full of StringTyped variables of this form:

    $foo = $condition? "TRUE": "FALSE";


  •  @markfiend said:

    This is an enterprise CMS, bought and paid for by the large educational establishment in England for which I work. Yes yes, TRWTF is php but I give you...

    // decide what to do
    switch($type) {
    	case 'class':
    	case 'include':
    	default:
    		return $hide;
    	break;
    }
    

     

    I too work in a (fairly large) education establishment in the UK. We take placement students to work on their PHP and Java (For no wage, of course). This makes them look good. Somehow.

     



  •  Does its name sound a bit like crack gourd?



  • Obviously that switch needs more exit points:

    // decide what to do
    switch($type) {
    	case 'class': return $hide;
    case 'include': $return = "hide";
    continue;
    default:
    return $hide;
    break;
    return $GLOBALS['hide'];
    default:
    continue; break;
    return $hide;
    }
    return $$return ?: $hide;

     

    Also the TRWTF is indeed PHP because you can apparently have multiple default: labels.  And "continue" in a switch means "break". Which is very surprising when your switch is in a loop.

     

     



  • @Master Chief said:

    Does its name sound a bit like crack gourd?

    Nope, and I'm not going to be drawn further. I want to keep my job!

    Also, superjer, do you want to come and work on this code? :-D



  • @markfiend said:

    Oh and this same piece of carp is full of StringTyped variables of this form:

    $foo = $condition? "TRUE": "FALSE";

     

     That's painfully redundant...

    I love the part where they took the effort to shorten the if - else structure to the ternary statement, yet that single line of code's so bloated it hurts.



  • What's even more fun is the several places where that $foo is used a few lines later in a construction like...

    if ($foo == "TRUE") {
        // do something
    } else {
        // do something else
    }

    ...and then never seen again.

    I'll say it again. This is something that our educational institution has paid for.



  • I think I may work for the company that produces that CMS... I found that "switch" code in our codebase, but I can't find any examples of the "$foo = $condition? "TRUE": "FALSE";" if that's in the public front-end part of the CMS, it may not even have been developed by us.

    This "large educational establishment" wouldn't happen to be a city university in the north would it?



  • @mallard said:

    ... I can't find any examples of the "$foo = $condition? "TRUE": "FALSE";" if that's in the public front-end part of the CMS, it may not even have been developed by us.
    Asking around, it might very well not have been.

    @mallard said:

    This "large educational establishment" wouldn't happen to be a city university in the north would it?
    Heh. No comment. Like I say, I want to keep my job.



  • @markfiend said:

    What's even more fun is the several places where that $foo is used a few lines later in a construction like...

    if ($foo == "TRUE") {
    // do something
    } else if ($foo == "FALSE") {
    // do something else
    } else {
    // file not found
    }

    ...and then never seen again.

    I'll say it again. This is something that our educational institution has paid for.

    No charge for fixing it for them, then!

     



  • @markfiend said:

    $foo = $condition? "TRUE": "FALSE";

    Yes, this particular construction seems to be the "personal pet" of one of the devs here, not from the original enterprise software.

    And while there are a few WTFs in there, (as I'm sure there are in any large codebase) this system is a positive dream to work on in comparison to my previous job...

    Is anyone aware of a CMS called vTiger? If not, go and download the tar.gz from here.

    Read it and weep.



  •  I know vTiger all too well.

     I think I've so far found 2 comments in it. Also, it's ugly as sin.



  • @markfiend said:

    @markfiend said:

    $foo = $condition? "TRUE": "FALSE";

    Yes, this particular construction seems to be the "personal pet" of one of the devs here, not from the original enterprise software.

    And while there are a few WTFs in there, (as I'm sure there are in any large codebase) this system is a positive dream to work on in comparison to my previous job...

    Is anyone aware of a CMS called vTiger? If not, go and download the tar.gz from here.

    Read it and weep.

     

    I thought that vTiger was a CRM, not a CMS, and was a fork of another open source CRM after some internal disputes. Somehow, I'm not surprised some things slipped QA in such a project.

     



  • @Thegoryone said:

    I know vTiger all too well.

    I think I've so far found 2 comments in it. Also, it's ugly as sin.

    My pet hate about vTiger: not only is there not a standard bracing-and-indentation style for the whole project, there are quite frequently several different bracing-and-indentation styles in any one file.

    I was virtually working as a one-man-shop supporting (and customising) vTiger in my previous job. I occasionally get tweets from my former junior, now replacement, at the old place, saying "Hey, I found another of your comments in here, swearing at the original developers". LOL

    Yeah, while (anonymous enterprise CMS) has the occasion WTF, I'm actually pretty happy to be working on it.

    And yes, vTiger is a CRM not a CMS. My Bad!



  • @The poop of DOOM said:

    I thought that vTiger was a CRM, not a CMS, and was a fork of another open source CRM after some internal disputes. Somehow, I'm not surprised some things slipped QA in such a project.
     


    It is, you're right - didn't notice that in his post. And it's a bag of shite

     



  • I don't know vTiger but I knew SugarCRM, from which it was forked.

    I once submitted a bug complaining about how there was a call to one of the most important methods in the system -- rendering a list view table -- where the arguments didn't really match the method's signature. The bug wasn't manifesting purely because of equal parts the nature of PHP and what values the arguments normally had.

    Because I annexed the correct code in the bug report (basically a one-liner with the correct arguments), they asked me to send them a printed statement -- by snail mail -- waiving any rights to intelectual property over the code.

    It was about then I realized I didn't really care enough to bother pushing the subject and just kept on with my life.

    Actually, this happened twice. The other time the code was a simple, dead obvious if statement around a block of pre-existing code.



  • @Zecc said:

    I don't know vTiger but I knew SugarCRM, from which it was forked.
     

    My company just recently set up SugarCRM just to try it out, though I haven't gotten a chance to look at it yet. Are there any glaring WTFs I should know about?



  • Last time I had anything to do with SugarCRM was two years ago and my memory is rather short, I'm afraid.

    I remember my biggest gripe back then was that with which version they seemed to focus more on creating new, buggy code for new shiny things than maintaining old, buggy code that was responsible for important stuff used everywhere. Like the code for loading bean properties or displaying list tables.

    But my major problem with Sugar was the lack of both in-code and out-of-code documentation. You had to dig around the source to find out how the code worked, and usually you would be disappointed to find just how much the code was inflexible in places, due to improper single responsibility and isolation. Also, although one of their highest selling points was that it was possible to edit the properties of your beans while using Sugar itself as an administrator, with the database being changed automagically, in truth some of the properties and relationships were hardcoded and you couldn't customize the way they worked without some serious edting of core source files. Which was a problem when it relates to upgrades.

    In short: the code was not incredibly terrible, stuff worked as expected most of time, and the interface sold well. But it wasn't something I'd be proud of if I had written it.


Log in to reply