cfparam broken in cfscript
I just ran into an issue with <cfparam> or at least the implementation of it inside a <cfscript> block.
To ensure a variable is defined using the <cfparam> tag you wold do
<cfparam name="url.id" />
If you hit this page without providing an id on the url you would get an error from ColdFusion, eg.
The required parameter URL.ID was not provided
However in cfscript there are two ways to write this
<cfscript> param url.id; // or param name="url.id"; </cfscript>
The first behaves exactly the same as its tag counter-part, but the second fails to throw an error if the variable is undefined.
I can't find any docs for cfparam in cfscript on adobe.com, but the second syntax is supported by ColdFusion builder, in fact it auto-suggests the name attribute when you type in param. So both should be supported, which means this is a bug.
I've posted a bug report here
Comments
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0999c-7ffa.html
param takes all of the same arguments that it's tag counterpart does, like this
param type="numeric" name="URL.Id" default="0";
If you aren't defaulting the value, then you can get some very unexpected results.
I had found that param took all the same arguments as cfparam, but that wasn't the point of my post. The issue is that depending on which script syntax you use you get different results.
The docs you link to show both syntaxes
a) param [type] name [=default]
b) param name="paramname" default="value"
The docs for cfparam say -
"To test whether a required variable exists, use this tag with only the name attribute. If it does not exist, ColdFusion stops processing the page and returns an error."
Thats a fairly unambiguous statement, and there should be no unexpected results, if you don't default the value and its undefined then cf throws an error. But this doesn't happen if you use syntax b above
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0999c-7ffa.html