Is there a way to globally apply the top attribute to cfdump / writeDump when working with ORM objects?

When working with nested ORM relationships, use cfdump or writeDump can quickly lead to java.lang.OutOfMemoryError errors because CF is trying to resolve the relationships in nested objects and dump too many objects.

This can be avoided with the top attribute, for example: <cfdump var=#SomeObject# top=3 />

It’s a pain to remember that you need to write all this time - is there a way to configure CF to not go down too many levels when working with ORM objects?

+4
source share
1 answer

There are no administrator settings for this. ( problem raised )

The wrong solution is to create a wrapper for the cfdump tag by renaming {cfusion}/wwwroot/WEB-INF/cftags/dump.cfm to (for example) origdump.cfm and then creating a new dump.cfm file containing:

 <cfif isObject(attributes.var) AND NOT StructKeyExists(attributes,'top')> <cfset attributes.top = 3 /> </cfif> <cforigdump attributecollection=#attributes# /> <cfexit method="exitTag" /> 

Fortunately, the writeDump function will call this wrapper (therefore, it works for both the tag and the function).

Unfortunately, the shell is not called recursively - if the ORM object is in a structure or an array, then the original problem still appears - perhaps a preliminary check of complex variables can be determined if there is an internal relationship and set the corresponding upper value, but this can be achieved only a limited solution (i.e. would affect neighboring structures / arrays).

+5
source

Source: https://habr.com/ru/post/1495291/


All Articles