Bug in CFDUMP tag - Doubling Your Output...

Posted by Dan on Aug 11, 2005 @ 9:19 PM

I discovered a small bug with CFMX today. It's certainly not a deal breaker and Macromedia is aware of the bug. (A birdy told me that they believe the bug has been fixed for Merrimack.)

When you have a UDF that writes to the output stream (using writeOutput() or <cfoutput>) and invoke the function directly from the <cfdump /> tag, the output is displayed twice. This had me pulling my hair out for about 30 minutes trying figure out why my output was being generated multiple times—I thought I had a bug in my code.

Anyway, to see the bug in action, run this code:

<cfscript>
function doubleDouble(){
    writeOutput("Double,");
    return "";
}
</cfscript>
<cfdump var="#doubleDouble()#">
<br />
<cfset sTest = doubleDouble()>
<cfdump var="#sTest#">

The output will be:

Double,Double, [empty string]
Double, [empty string]

Notice how when the doubleDouble() function is called directly in the <cfdump /> tag the output is doubled, but when saved in a variable the output is only generated once. Like I said, not a really a show stopper, but I often use <cfdump /> to test my UDFs. I'm surprised I've never noticed this bug before.

Categories: HTML/ColdFusion

Comments for this entry have been disabled.