Raymond Camden's Blog Rss

Two Nice Fixes in ColdFusion 7.0.1

22

Posted in ColdFusion | Posted on 09-28-2005 | 5,412 views

I double checked the release notes and didn't see a mention of this - but two nice bug fixes are in ColdFusion 7.0.1 that relate to Application.cfc.

First - remember the bug where cflocation calls would run onError? That is fixed.

The second bug involved onSessionEnd. If you did not specify a specific session timeout value and relied on the default in the ColdFusion Admin, the onSessionEnd event would never fire. This has been fixed as well.

Comments

[Add Comment] [Subscribe to Comments]

I don't know Ray, I'd say that having a <cflocation> anywhere in Application.cfc is an error. You're right that the server behavior was a bug, but I've qot to question putting a <cflocation> in any event other than onError(). To me that's a bad practice. The only place I could see possibly putting one is in the onError() method.
The use of a <cflocation> tag anywhere in the application could trigger the onError() event. The same applies to using the <cfabort> tag within a processing block, it would trigger the onError() event as well. I believe this was due to the onError() event not filtering out the internal error type thrown by those tags.
Simon, you misread, see the comment above mine. Btw, anon, why hide?
I was sure I've done <cflocation>s in apps that had onError methods... but maybe not. Sorry for that, I thought you were refering to using <cflocation> inside an event handler, which I dissaprove of.
I'm glad you got bugfixes - all I got was mure bugs! cffile action="upload" is completely broken in 7.01. If you do

cffile action="upload" destination="c:\temp\test.jpg"

CF creates a directory named test.jpg and then puts your file in it, so it winds up at c:\temp\test.jpg\test.jpg.

:(
That's not a bug. The Destination attribute expects the folder, not the filename.
In all versions up to version 7, passing in a file name worked! So at the very least, it's a breaking change, and the change in behavior isn't mentioned in the release notes :(
That is like putting Pound signs in your cfml code, you can do it but it doesn't make it correct just because it doesn't through an error.

just my 2 cents.
Actually, the documentation (pre 7.01) even included examples of using the tag this way, so I wouldn't exactly call this usage incorrect. Anyway, the little birdies have told me that this is going to be returned to its old behavior in a hotfix which will come out soon.
Roland, they posted a hot fix today.
Yep - I helped "inspire" it ;)
Ray:

Before the updater I had a gridcol with both dates and text (the query that populated the grid would return "exhausted" if the date was less than today, or "greater than 5 years" if applicable - or simply a date in the mm/dd/yyyy format). In my cfgridcolumn I added type="date" and everything worked out perfect - the dates sorted correctly and the text items were grouped accordingly. After the updater, any non-date text items are turned into blank cells in the grid. Removing type=date returns the text and the dates to the column, but doesn't sort correctly. What gives?

Also - where is the Ask a jedi box and all the other links, etc on your site? They're gone!?
No idea on your cfgrid issue, but as for the layout, its a stupid IE bug with this template. Whenever I have content that is a bit too wide, it breaks in IE. It should be fixed now.
Indeed it is fixed.

Would my issue be considered a bug since it is a change in functionality that produces an undesired result? After all, it worked before the updater...

If so, how do I report that?
I believe the URL is www.macromedia.com/go/wish.
The updater 7.1 shows a blank page when using CFLOCATION on any page. This is because I am using the OnRequest method on Application.cfc, it raises an exception. Earlier the exception would be caught by OnError method but now the behavior has changed. An ideal fix will be to change the CFLOCATION behavior on Application.cfc so that its use does not raise an exception if it is being called with in OnRequest Method.
Is your cflocation in the method itself or in the page? cflocation works in pages just fine for me in 7.0.1. I also added, in onrequest, logic that said, if you are requesting index.cfm, cflocate to index2.cfm, and that ran fine.

Do not forget that you MUST cfinclude the file or it will not load. If you ONLY have a cflocation in onRequest, you will not see anything.
Here is some code to reproduce the issue, create a new folder in your site to see if you too get the blank screen error. I can send you the URL of our DEV site via email if you want to see it in action.

<!--- ************************** Application.cfc ************************** --->
<cfcomponent output="false">

   <cfscript>
      this.name="Debug_CFLOCATION";
      this.sessionManagement=true;
      this.applicationTimeout=createtimespan(2,0,0,0);
      this.sessionTimeout=createtimespan(0,0,30,0);
   </cfscript>
   
<cffunction name="onApplicationStart" returntype="void" output="false">
</cffunction>


<cffunction name="onSessionStart" returntype="void" output="false">
</cffunction>


<cffunction name="onRequestStart" returntype="void" output="false">
</cffunction>
   
<cffunction name="onRequestEnd" returntype="void" output="false">      
</cffunction>


<cffunction name="onSessionEnd">
</cffunction>
      
<cffunction name="onApplicationEnd" output="false">
</cffunction>

<cffunction name="onError">
   
<cfargument name="Exception" required="true"/>
<cfargument type="String" name = "EventName" required="true"/>
      
      <cfswitch expression="#arguments.exception.rootcause.type#">
         <cfcase value="coldfusion.runtime.AbortException">
            <cfreturn/>
         </cfcase>
         <cfdefaultcase>
            <cfdump var="#exception#"/>
         </cfdefaultcase>
      </cfswitch>
      
</cffunction>         
         
</cfcomponent>

<!--- ************************** Index.cfm ************************** --->
<cfparam name="form.submit" default=""/>
<cfparam name="url.logoff" default="0"/>

<cfif len(form.submit)>
   <cfset session.user = form.user/>
   <cflocation url="index.cfm" addtoken="no"/>
<cfelseif url.logoff>
   <cfscript>
      structDelete(session,"user");
      StructClear(session);
   </cfscript>
   <cflocation url="index.cfm" addtoken="no"/>   
</cfif>

<cfif IsDefined("session.user") and len(session.user)>
   User <cfoutput><b>#session.user#</b></cfoutput> logged in<br />
   <a href="index.cfm?logoff=1">Log Off</a>
<cfelse>
   <cfform action="index.cfm" method="post" name="frmLogin">
      User Name:<input type="text" size="12" name="user"/>&nbsp;<input type="submit" name="submit" value="Log In"/>
   </cfform>   
</cfif>
Ray, also you must have noticed that I took even the OnRequest method out in this sample, so its something to do with CFLOCATION behivor rather than Application.cfc behavior. This used to work fine before CF 7.1.
This indeed was a CFLOCATION issue, and happens when running JRun with updater 6, here is the link to the hot fix provided by Macromedia for this
http://www.macromedia.com/cfusion/knowledgebase/in...
Anu, so it sounds like you are all ok then?
I am running 7.0.1 and CFLOCATION still causes onError to trigger. I put the code from the earlier 7.0 post into the code, and it at least doesn't trigger my error emails anymore.

[Add Comment] [Subscribe to Comments]