Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SerializeJSON Only Returning First Two Records

I have an issue where serializing an ORM relationship is only showing the first two records. The rest just show [] blank.

Here is an example relationship:

property name="endorsements" singularname="endorsement" fieldtype="one-to-many" lazy="false" fkcolumn="xxx" cfc="endorsements" remotingfetch="true";

Getting the JSON:

policy = entityLoad("policy",1018379202)[1];
serializeJSON( policy );

And a cut down part of the JSON:

{"id":12321,"endorsements":[{"effectiveDate":"July, 01 2009 00:00:00","active":true},
{"effectiveDate":"July, 01 2009 00:00:00","active":true},
"","","","","","","","",""]}

The empty strings should be other records in the relationship.

I've verified via debug files that the Hibernate query is bringing back all records and a cfdump shows this as well.

Thoughts?

like image 928
Sam Farmer Avatar asked Mar 21 '12 22:03

Sam Farmer


1 Answers

The bug occurs in coldfusion.runtime.JSONUtils.serializeJSON() at around line 409.

If you are serialising a persistent cfc, it adds the fully qualified name of the cfc to an ArrayList, which is passed around recursively.

Then there is an if() statement which tries to locate the cfc's fully qualified name and once it appears more than twice in the list, leaves the function early with "{}".

Not really sure what they were trying to accomplish with this if(). Possibly to handle circular references?

This bug was logged back in April: https://bugbase.adobe.com/index.cfm?event=bug&id=3175667

like image 56
Mike Causer Avatar answered Oct 01 '22 22:10

Mike Causer