tracker issue : CF-4202006

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

Subclass cfc loses property type info from parent during SerializeJSON()

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): James Partin / ()

Created: 04/17/2018

Components: Language, Serialization

Versions: 2016

Failure Type: Data Corruption

Found In Build/Fixed In Build: 2016,0,04,302561 / ColdFusion 2018

Priority/Frequency: Normal / All users will encounter

Locale/System: ALL / Windows 7 64-bit

Vote Count: 0

Problem Description:
SerializeJSON loses type info from properties defined in the parent class when serializing a subclass.

Steps to Reproduce:
foo.cfc:
{code:java}
/**
* @output false
* @accessors true
**/
component{

	/**
	* @getter true
	* @setter false
	**/
	property string numStr;

	variables.numStr = "";

	/**
	* @output false
	**/
	public foo function init(){
		variables.numStr = "1234";

		return this;
	}
}
{code}

bar.cfc:
{code:java}
/**
* @output false
* @accessors true
* @extends foo
**/
component{

	/**
	* @output false
	**/
	public bar function init(){
		variables.numStr = "1234";

		return this;
	}
}
{code}


test.cfm:
{code:java}
<cfscript>
	cFoo = new foo();
	Writeoutput(SerializeJSON(cFoo)); //{"numStr":"1234"}

	cBar = new bar(); //inherits from foo.cfc
	Writeoutput(SerializeJSON(cBar)); //{"numStr":1234} //do you even datatype bro??
</cfscript>
{code}


Actual Result:
{"numStr":1234}

Expected Result:
{"numStr":"1234"}

Any Workarounds:
None. Tried setting metadata on variables scope in the cfc, but naturally, variables scope is not a true struct.

Attachments:

Comments:

That's all well and good that it's fixed in 2018, but it's not out yet and at best is several months away, and it'll take a few months of proper shakedown of 2018 when it does release before I switch production over to it. So how about let's make sure it gets patched into at least 2016 if not cf11, since thats what everyone currently uses?
Comment by James P.
27455 | April 19, 2018 03:56:56 PM GMT