tracker issue : CF-4120116

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

[ANeff] Bug for: thread attribute variables unusable in cfhtmltopdf/cfdocument header/footer

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff (Aaron Neff)

Created: 02/20/2016

Components: Document Management

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Normal / Some users will encounter

Locale/System: English / Platforms All

Vote Count: 0

Listed in the version 2016.0.02.299200 Issues Fixed doc
thread attribute variables unusable in cfhtmltopdf/cfdocument header/footer unless local-scoped first

----------------------
cfhtmltopdfitem repro:
----------------------

<cfscript>
  mySimpleValue = 1;
  myArray = [variables.mySimpleValue];
  myStruct = {mySimpleValue=variables.mySimpleValue};
  thread action="run" name="myThread#variables.mySimpleValue#" mySimpleValue=variables.mySimpleValue myArray=variables.myArray myStruct=variables.myStruct {
	  cfhtmltopdf(name="THREAD.myPDF") {
		  //example 1
		  cfhtmltopdfitem(type="header") {writeOutput(ATTRIBUTES.mySimpleValue);}//throws: "An error has occurred while retrieving content for setting Header/Footer."
		  /*var foo = ATTRIBUTES.mySimpleValue;
		  cfhtmltopdfitem(type="header") {writeOutput(foo);}*///workaround 1
		  //example 2
		  //cfhtmltopdfitem(type="header") {writeOutput(ATTRIBUTES.myArray[1]);}//throws: "An error has occurred while retrieving content for setting Header/Footer."
		  /*var foo = ATTRIBUTES.myArray[1];
		  cfhtmltopdfitem(type="header") {writeOutput(foo);}*///workaround 2
		  //example 3
		  //cfhtmltopdfitem(type="header") {writeOutput(ATTRIBUTES.myStruct.mySimpleValue);}//throws: "An error has occurred while retrieving content for setting Header/Footer."
		  /*var foo = ATTRIBUTES.myStruct.mySimpleValue;
		  cfhtmltopdfitem(type="header") {writeOutput(foo);}*///workaround 3
		  
		  writeOutput(ATTRIBUTES.mySimpleValue & ' | ' & ATTRIBUTES.myArray[1] & ' | ' & ATTRIBUTES.myStruct.mySimpleValue);
	  }
  }
  threadJoin();
  for(item in CFTHREAD) {
	  if(CFTHREAD[item].keyExists("error")) {
		  writeDump(CFTHREAD[item].error);
	  }
  }
</cfscript>

Actual result: Error thrown (see comments) if thread attribute variable is directly referenced inside cfhtmltopdfitem body

Expected result: No error thrown when thread attribute variable is directly referenced inside cfhtmltopdfitem body

----------------------
cfdocumentitem repro:
----------------------

<cfscript>
  mySimpleValue = 1;
  myArray = [variables.mySimpleValue];
  myStruct = {mySimpleValue=variables.mySimpleValue};
  thread action="run" name="myThread#variables.mySimpleValue#" mySimpleValue=variables.mySimpleValue myArray=variables.myArray myStruct=variables.myStruct {
	  cfdocument(format="pdf", name="THREAD.myPDF") {
		  //cfdocumentitem(type="header") {writeOutput(ATTRIBUTES.mySimpleValue);}//throws: "Element MYSIMPLEVALUE is undefined in ATTRIBUTES."
		  /*var foo = ATTRIBUTES.mySimpleValue;
		  cfdocumentitem(type="header") {writeOutput(foo);}*///workaround
		  //cfdocumentitem(type="header") {writeOutput(ATTRIBUTES.myArray[1]);}//throws: "Element MYARRAY is undefined in ATTRIBUTES."
		  /*var foo = ATTRIBUTES.myArray[1];
		  cfdocumentitem(type="header") {writeOutput(foo);}*///workaround
		  //cfdocumentitem(type="header") {writeOutput(ATTRIBUTES.myStruct.mySimpleValue);}//throws: "Element MYSTRUCT.MYSIMPLEVALUE is undefined in ATTRIBUTES."
		  /*var foo = ATTRIBUTES.myStruct.mySimpleValue;
		  cfdocumentitem(type="header") {writeOutput(foo);}*///workaround
		  writeOutput(ATTRIBUTES.mySimpleValue & ' | ' & ATTRIBUTES.myArray[1] & ' | ' & ATTRIBUTES.myStruct.mySimpleValue);
	  }
  }
  threadJoin();
  for(item in CFTHREAD) {
	  if(CFTHREAD[item].keyExists("error")) {
		  writeDump(CFTHREAD[item].error);
	  }
  }
</cfscript>

Actual result: Error thrown (see comments) if thread attribute variable is directly referenced inside cfdocumentitem body

Expected result: No error thrown when thread attribute variable is directly referenced inside cfdocumentitem body

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

Watson Bug ID:	4120116

External Customer Info:
External Company:  
External Customer Name: Aaron Neff
External Customer Email:

Attachments:

Comments:

(Continued b/c forum said description must be less than 4000 characters) ------------------------------------ Issue does not affect cfmail (good): ------------------------------------ <cfscript> mySimpleValue = 1; myArray = [variables.mySimpleValue]; myStruct = {mySimpleValue=variables.mySimpleValue}; thread action="run" name="myThread#variables.mySimpleValue#" mySimpleValue=variables.mySimpleValue myArray=variables.myArray myStruct=variables.myStruct { cfmail(from="a@a.com", to="b@b.com", subject="my subject") { cfmailpart(type="text") { writeOutput(ATTRIBUTES.mySimpleValue & ' | ' & ATTRIBUTES.myArray[1] & ' | ' & ATTRIBUTES.myStruct.mySimpleValue); } } } threadJoin(); for(item in CFTHREAD) { if(CFTHREAD[item].keyExists("error")) { writeDump(CFTHREAD[item].error); } } </cfscript> Actual and expected result: No error thrown (good) and email generated successfully So, the issue seems to be specific to cfhtmltopdfitem and cfdocumentitem.
Comment by External U.
4522 | February 20, 2016 03:09:19 PM GMT
Tested w/ CF11 Update 7 (build 11,0,07,296330) and CF2016 (build 2016.0.0.297996).
Comment by External U.
4523 | February 20, 2016 03:11:16 PM GMT
thread attributes were not visible inside cfhtmltopdfitem/cfdocumentitem. The reason was that for cfhtmltopdfitem/cfdocumentitem a new UDF is genarated and a new function scope is pushed which overrides the thread attributes. Now thread's attributes are merged with cfhtmltopdfitem/cfdocumentitem before invoking the genarated function.
Comment by Chinoy G.
4524 | April 11, 2016 05:53:48 AM GMT
Verified in build: 298998
Comment by Kailash B.
4525 | May 24, 2016 07:43:57 AM GMT
test note
Comment by CFwatson U.
4526 | June 07, 2016 04:19:06 AM GMT
The fix for this bug is available as part of the early-access build for ColdFusion 2016 Update 2.
Comment by CFwatson U.
4527 | June 07, 2016 04:25:52 AM GMT