Wednesday, March 17, 2010

ColdFusion cfswitch bug not completely fixed...

I remember a bug in ColdFusion where a long cfswitch statement would throw an error.   This was thought to be fixed, however it still does exist when using switch and case statements inside of a cfscript tag.

<cfscript>
switch(fuse)
 {
  case "login":
  {
   ArrayAppend(IncludeArray,"DisplayFiles\dsp_Login.cfm");
   break;
  }
  case "logout":
  {
   include("ActionFiles\act_logout.cfm");   
   relocate("index.cfm?fuse=login&message=You have been successfully logged out.");
   break;
  }

I have a large controller (2500 lines or so) file that makes a lot of object calls within my switch statements and when using switch and case statements within cfscript I would get a "Invalid method Code length" error.   Once I converted the switch statements to markup everything worked fine...

<cfswitch expression="#fuse#">
  <cfcase value= "login">
  <cfscript>
   ArrayAppend(IncludeArray,"DisplayFiles\dsp_Login.cfm");
   </cfscript>
  </cfcase>
  <cfcase value= "logout">
  <cfscript>
   include("ActionFiles\act_logout.cfm");   
   relocate("index.cfm?fuse=login&message=You have been successfully logged out.");
   </cfscript>
  </cfcase>

4 comments:

  1. have you filed the bug? http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html

    ReplyDelete
  2. No I didn't. I'm not sure why either, I filed a bug with Adobe the second I found something wrong with CFBuilder.

    ReplyDelete
  3. Is this a CFSwitch-specific problem? Or a file-length problem? I remember reading somewhere that a file can only be a certain size - perhaps the long switch is just crossing that threshold.

    Of course, if that were the case, I am not sure why a tag version would be less likely to break. I guess this is a unique problem.

    ReplyDelete
  4. Ben, do you know of a tool that will let me see the classes that ColdFusion creates under the hood when it compiles a template? I'd like to see the difference in a class that uses cfscript vs tags for a case statement.

    ReplyDelete

Fork me on GitHub