Nov 262009
 

Going through some testing as part of our upgrade to Coldfusion 9 I encountered a compatibility issue that is worth knowing about. In Coldfusion 9 there is now a variable status “undefined”, that is the variable can exist (and appear in cfdump for example) but is not usable, it is explicitly undefined. This is a problem because if you try and use cfparam later for example it doesn’t override the “undefined” variable. So far the only place I’ve seen this is when using components, and then to be fair the condition arose because of some inconsistent defaulting so it’s not completely the fault of the new process but it’s worth being aware of if you are getting unexplained “undefined” errors when moving up to Coldfusion 9.

Ok so consider the following:

<CFFUNCTION name=”getByCriteria” access=”public” returntype=”query” output=”false” displayname=”” hint=””>
<CFARGUMENT name=”child_ocl_id” required=”false” >

This will result in an explicitly set variable that is set to “undefined” – the cfdump is thus:

cfdump_with_undefined_variable

Note the explicitly “undefined” status as well as (what my code was expecting) the “[empty string]” status

This stays the same whether you add a cfparam later or not, thus:

<CFFUNCTION name=”getByCriteria” access=”public” returntype=”query” output=”false” displayname=”” hint=””>
<CFARGUMENT name=”child_ocl_id” required=”false” >
<CFPARAM name=”arguments.child_ocl_id” default=”my new default” >

Note the above example isn’t what was in my code! It’s just a simple explanation of the behaviour I noticed. So just something to be aware of if you get unexplained “undefined” errors in your migration to Coldfusion 9.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.