tracker issue : CF-3364510

select a category, or use search below
(searches all categories and all time range)
Title:

CFPARAM functionality missing from param

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 11/13/2012

Components: Language

Versions: 9.0.1

Failure Type:

Found In Build/Fixed In Build: 9.0.1 / 286560

Priority/Frequency: Major / Most users will encounter

Locale/System: English / Win XP All

Vote Count: 1

Problem Description:
With <cfparam> one can do this:

<cfparam name="variables.myRequiredVariable">

This will cause an exception to be raised if variables.myRequiredVariable does not exist.  The equivalent functionality for param would be this:

param name="variables.myRequiredVariable";

This however does not work: no exception is raised, and the code continues to run.


Steps to Reproduce:
See above

Actual Result:
See above

Expected Result:
See above

Any Workarounds:
Use structKeyExists() and a throw(), but this is less than ideal.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3364510

External Customer Info:
External Company:  
External Customer Name: Adam Cameron.
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

Works fine with and w/o cfclient. Can you please reverify.
Comment by Chandan ..
17237 | October 28, 2013 10:18:05 AM GMT
It's broken. Like I said. https://gist.github.com/adamcameroncoldfusion/7200083
Comment by External U.
17238 | October 28, 2013 11:00:52 AM GMT
Not sure what CFCLIENT has to do with anything...
Comment by External U.
17239 | October 28, 2013 08:17:19 PM GMT
Chandan, how did you conclude this is "not a bug" before you even understood what the issue was? This seems a bit premature, don't you think? -- Adam
Comment by External U.
17240 | October 29, 2013 03:30:56 PM GMT
I verified the same problem exists in 9.0.2 (checked it on CFLive.net). However, Railo does correctly throw an exception with both <cfparam> and param. This is definitely a bug!
Comment by External U.
17241 | October 29, 2013 03:54:14 PM GMT
Thanks Carl. Thinking about it, I'd also quite like to know how Chandan conclude this WASN'T a bug. What exactly did you test? Not the code in the ticket. -- Adam
Comment by External U.
17242 | October 29, 2013 04:01:21 PM GMT
Ben Nadel explored this further and has some additional code samples to test against: http://www.bennadel.com/blog/2550-Very-Strange-Script-Based-Behavior-For-CFParam-In-ColdFusion.htm
Comment by External U.
17243 | October 31, 2013 09:32:18 PM GMT
Param and CFPARAM should behave identically.
Vote by External U.
17248 | October 31, 2013 09:33:42 PM GMT
There are two constructs for param in script syntax param [type] varname[= default]; param [key1=value1]; now param name = "varname"; falls under type 1 as well. So this got treated as name="name" and default="varname" As a fix we would treat this as special case (with name as key and no return type) and would fall to type 2 (which is the tag's behavior)
Comment by Chandan ..
17244 | November 04, 2013 10:10:20 AM GMT
I think rather than building in "special cases", you should simply check to see whether it fits the attribute="value" style syntax (type 2) first. <cfparam> (and accordingly param) has a closed subset of value attribute combinations, so this is a closed loop as far as possibilities go. Then IFF no sense can be made that way, fall back to type 2 syntax. Don't hard-code exceptions into your code. That'd be a bad approach. -- Adam
Comment by External U.
17245 | November 04, 2013 11:40:47 AM GMT
With returntype being optional, type 1 will always fall under type 2. Whole purpose of adding type 1 was to give a shorthand notation for common usage of param i.e. providing name, default and return type. More than one key=value pair will anyways be treated as type 2. And also name is a mandatory field for cfparam. So this fix solves all the cases except when variable's name is name (would need to use type 2 syntax). Marking "name" as special key removes this ambiguity.
Comment by Chandan ..
17246 | November 04, 2013 11:56:09 AM GMT
added test case: qa\cf\regression\coretests\coldfusion\tags\variable-manipulation\cfparam\param\bugCF-3364510.cfm
Comment by Suchika S.
17247 | December 03, 2013 07:39:48 AM GMT