The case of the missing parents, or useless useless useless



  •  So today I went investigating how some records magically disappeared from the database of the application I have inherited. What I found is well judge for yourself.

    To give you an idea of what I found a table exists which references the users table and has 8550 records of which 625 are orphaned. Naturally I checked to see why the delete user function was not clearing up these records. Putting aside the lack of any constraints or foreign keys or even primary key constraints IN THE WHOLE DATABASE. This is what I found. (obfuscated to protect myself and not the idiot who wrote it).

     <cffunction name="deleteUser" returntype="string" hint="returns user details query">
               <cfargument name="userID" type="numeric" required="yes">
               <cfparam name="userID" default="0">
                
                <CFQUERY name="UserID" datasource="#request.dsn#">
                select     UserID
                from     users
                where     userID = <CFQUERYPARAM value="#userID#" cfsqltype="CF_SQL_INT">
                </CFQUERY>
                
                <CFQUERY name="qDeleteuser" datasource="#request.dsn#">
                delete
                from    users
                where     userID = <CFQUERYPARAM value="#userID#" cfsqltype="CF_SQL_INT">
                </CFQUERY>                                   
            

     

     

     

     

            <cfreturn "deleted">

        </cffunction>

    To anyone who is not familiar with coldfusion here is a list of the WTF's.

    1. The function definition contains a hint record saying it returns a user record
    2. The function accepts  a userId as a required argument, then uses the cfparam to ensure that the userid variable (which was just declared as required in the line above) actually exists.
    3. Function does nothing prevent orphan records (remember database does not either)
    4. Function first gets the user record by id...just because.
    5. Function finally deletes the record, again not doing anything to prevent orphans
    6. Finally a string value of "deleted" is returned...always...no matter what!
    Oh and code indenting added for readability, it does not exist in the real code...but I did leave in the whitespace to give you some idea of how it actually looks.



  • I'm thinking the whitespace was probably where they originally tried to clean up child records, but couldn't get it to work so removed the code. Or else the space where they planned to put the code to remove child records, but never got around to actually writing it. Of course sensible use of foreign keys and CASCADE CONSTRAINTS would have been better; but manually deleting child records of the given parent would have worked reasonably well, if only they'd actually done it.



  • You're working in ColdFusion? How come you haven't killed yourself yet?



  • Oblig TRWTF is ColdFusion



  • No really, ColdFusion is the real WTF.

    The hell. Why isn't that dead yet?



  • @dhromed said:

    No really, ColdFusion is the real WTF.

    The hell. Why isn't that dead yet?

    Because designers who think that knowing HTML makes them 1337 c0d3r5 refuse to let it die.



  •  Oh god I knew it. I just knew somebody would say it. Maybe let's just make a template stating that "the real wtf is <INSERT_NAME_HERE>" and use it every time PHP, ColdFusion, VB or Haskell is mentioned (because fuck Haskell).

    And no, not in this case. It's not Cold Fusion's fault.



  • @Kiss me I'm Polish said:

    It's not Cold Fusion's fault.

     

    Yeah, but it's sure not helping the situation.



  • @Kiss me I'm Polish said:

     Oh god I knew it. I just knew somebody would say it. Maybe let's just make a template stating that "the real wtf is <INSERT_NAME_HERE>" and use it every time PHP, ColdFusion, VB or Haskell is mentioned (because fuck Haskell).

    And no, not in this case. It's not Cold Fusion's fault.

    What do you have against Haskell? I've never used it but heard it's better than Java, although frankly that's not a particularly strong endorsement since a root canal is better than Java.



  •  Haskell is a hard language and appears to have no niche. As in, for everything you might do with Haskell, you could just as well use Python, Perl or Lisp and more people would be able understand your code.



  • @Kiss me I'm Polish said:

    It's not Cold Fusion's fault.
     

    Yes it is. ColdFusion was invented by sadists. It needs to go away right now.

    Besides, the WTF here is relatively shallow. What else can we talk about?



  • @The_Assimilator said:

    @Kiss me I'm Polish said:

     Oh god I knew it. I just knew somebody would say it. Maybe let's just make a template stating that "the real wtf is <INSERT_NAME_HERE>" and use it every time PHP, ColdFusion, VB or Haskell is mentioned (because fuck Haskell).

    And no, not in this case. It's not Cold Fusion's fault.

    What do you have against Haskell? I've never used it but heard it's better than Java, although frankly that's not a particularly strong endorsement since a root canal is better than Java.

    Nothing, it's great. I wouldn't compare it to Java, because it has a different purpose.

    Anyway I said Haskell, but I could have said Erlang, Ada or F# because almost nobody uses these either so almost nobody would take it personally. And everybody is used to bashing of PHP and VB so nobody would care either.



  • @dhromed said:

    @Kiss me I'm Polish said:

    It's not Cold Fusion's fault.
     

    Yes it is. ColdFusion was invented by Macromedia. It needs to go away right now.

    Besides, the WTF here is relatively shallow. What else can we talk about?

    FTFY.

    ... oh wait, I forgot that Macromedia/Adobe are sadists.



  • @dhromed said:

    ColdFusion was invented by sadists. It needs to go away right now.
     

    If I recall correctly, it was also used to build MySpace, which means it needs to go away even sooner.



  • I once tried to install it and it required some sort of Java app server to run on top of. I might be wrong and I've tried mightily to block the specifics of that particular experience from becoming memories.



  • @The_Assimilator said:

    What do you have against Haskell? I've never used it but heard it's better than Java, although frankly that's not a particularly strong endorsement since a root canal is better than Java.
     

    I haven't coded in Haskell or Java but have had root canal work performed on three continents.  



  • TRWTF is using request.DSN

    1999 called, they want their methodology back.

    And for those that haven't checked lately, CF has come a long way in the last couple years. No really! CF9 has all kinds of cool stuff. You can write entire applications, sensibly, without a single angle bracket and without using "CF" once. From an implicit default constructor, to implicit autocreation of accessors and mutators for properties, to greatly expanded script syntax, CF9 ain't your dad's CF now.



  • @The_Assimilator said:

    @dhromed said:

    @Kiss me I'm Polish said:

    It's not Cold Fusion's fault.
     

    Yes it is. ColdFusion was invented by the Allaire brothers. It needs to go away right now.

    Besides, the WTF here is relatively shallow. What else can we talk about?

    FTFTFY.

    Allaire Corporation were bought up by Macromedia years ago, before they in turn got swallowed by Adobe.

    Macromedia took on also Allaire's HomeSte+ HTML editor; I remember discovering that if you wrote window.close(); on a page and viewed inside the HomeSite+ IE control:

    The embedded IE control would shut itself down and crash HomeSite+:

    Also, window.moveBy(…) works on both maximised windows:

    And the embedded IE control:

    Good times. Excuse the unpleasant dithering – I was trying to be dial-up friendly when I originally posted those screenshots and I no longer have the masters for all the images I butchered with dithering and JPEG compression. Also wish I had a) the full uncropped versions and b) hadn't dropped down to 800×600 to reduce the image sizes.



  • @Daniel Beardsmore said:

    Allaire Corporation were bought up by Macromedia years ago, before they in turn got swallowed by Adobe.

    Macromedia took on also Allaire's HomeSte+ HTML editor

    I encountered a client using HomeSite 5 about a year ago. They couldn't install the JavaScript I delivered to them because it had lines that were too long-- I don't remember what the limit was, but I do remember being shocked that it had a limit at all. Then I found out it was from like 2000.



  • @blakeyrat said:

    @Daniel Beardsmore said:

    Allaire Corporation were bought up by Macromedia years ago, before they in turn got swallowed by Adobe.

    Macromedia took on also Allaire's HomeSte+ HTML editor

    I encountered a client using HomeSite 5 about a year ago. They couldn't install the JavaScript I delivered to them because it had lines that were too long-- I don't remember what the limit was, but I do remember being shocked that it had a limit at all. Then I found out it was from like 2000.

    Everything has limits. Sometimes the limits are known to us, before hand so that we can work aruond them. At times, the limits are not known, when it result to frustration.



  • Okay, I've never touched ColdFusion, so I'm probably behind the times, but who the fuck thought it would be a good idea to code functions using XML (actually, I guess that's more HTML, since the cfreturn element is not closed)? WHAT THE FUCK?



  •  @toth said:

    Okay, I've never touched ColdFusion, so I'm probably behind the times, but who the fuck thought it would be a good idea to code functions using XML (actually, I guess that's more HTML, since the cfreturn element is not closed)? WHAT THE FUCK?

    Toth, how about functions that retardedly required their input to be strings. It's been a long time since I had to <cf, but it went something like <cfif "n gt 5">N greater than 5<cfelse>N not greater than 5</cfif>. The if parameters were a parsed string, instead of a boolean.  I can't remember exactly if it was cfif or which one it was. 



  • @EJ_ said:

     @toth said:

    Okay, I've never touched ColdFusion, so I'm probably behind the times, but who the fuck thought it would be a good idea to code functions using XML (actually, I guess that's more HTML, since the cfreturn element is not closed)? WHAT THE FUCK?

    Toth, how about functions that retardedly required their input to be strings. It's been a long time since I had to <cf, but it went something like <cfif "n gt 5">N greater than 5<cfelse>N not greater than 5</cfif>. The if parameters were a parsed string, instead of a boolean.  I can't remember exactly if it was cfif or which one it was. 

    Holy shit. So why did anyone ever use this crap? Who gave the splendid sales presentation that made this seem not like Ark-of-the-Covenant-face-melting horrible?



  • @toth said:

    Holy shit. So why did anyone ever use this crap? Who gave the splendid sales presentation that made this seem not like Ark-of-the-Covenant-face-melting horrible?

    Cold Fusion was created by Macromedia.
    It was marketed to graphic designers.
    Graphic designers love Macromedia.
    Graphic designers are stupid.
    Graphic designers control budgets completely disproportionate to their intelligence.
    Therefore, Cold Fusion exists because of stupid people. (Many other languages that should not exist, but do, exist for the same reason. Like VB, for instance.)



  • @The_Assimilator said:

    @toth said:
    Holy shit. So why did anyone ever use this crap? Who gave the splendid sales presentation that made this seem not like Ark-of-the-Covenant-face-melting horrible?

    Cold Fusion was created by Macromedia.

    Seriously WTF? I've already said that it was created by Allaire. Macromedia bought it around version 5, I think.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.