Coldfusion, The symbol you provided [method_name] is not a function

社会主义新天地 提交于 2020-01-03 16:57:00

问题


Running CF 9,0,1,274733

I have a custom DAO CFC with a method called getGamesBetTypesID().

The method is generated/synthesized implicitly by CF from the following property:

<cfproperty name="gamesBetTypesID" type="numeric" />

A default variable is defined as follows:

<cfset VARIABLES.gamesBetTypesID = 0 />

Other than that there are no other VARIABLES, vars, LOCALs, ARGUMENTS or methods called getGamesBetTypesID. All CFC and function variables are correctly scoped.

This save() method is called thousands of times, but the following error gets thrown randomly and only a handful of times.

Detail: The symbol you provided getGamesBetTypesID is not the name of a function. 
Message: Entity has incorrect type for being called as a function. 

Here's the save() method:

<cffunction name="save" access="public" returntype="void" output="false">

    <cfif getGamesBetTypesID() eq 0 or getGamesBetTypesID() eq "">
        <cfset create() />
    <cfelse>
        <cfset update() />
    </cfif>

</cffunction>

When the error gets thrown I log a dump of the CFCs metadata using getMetaData(gamesBetTypesObj). According to the meta data the function getGamesBetTypesID does exist.

Has anybody else some across this before? I've read that it can happen due to naming and scope collisions, of which I have none.

Thanks in advance.


回答1:


After posting the question above I removed <cfproperty name="gamesBetTypesID" type="numeric" /> and added an explicit getter and setter for VARIABLES.gamesBetTypesID.

<cffunction name="getGamesBetTypesID" output="false" access="public" returntype="numeric">
    <cfreturn VARIABLES.gamesBetTypesID />
</cffunction>

<cffunction name="setGamesBetTypesID" output="false" access="public" returntype="void">
    <cfargument name="gamesBetTypesID" required="true" type="numeric" />
    <cfset VARIABLES.gamesBetTypesID = ARGUMENTS.gamesBetTypesID />
</cffunction>

This code has been running in production for a week, including a weekend, which is our busy period. Not one exception has been thrown in the last 7 days. Previously, up to 15 exceptions were being thrown on a busy day.

This leads me to believe that there is a bug in the generation/use of implicit accessors by way of <CFPROPERTY> that only appears in certain situations. I'm going to log a bug with Adobe

I'll update if any progress is made.



来源:https://stackoverflow.com/questions/7689204/coldfusion-the-symbol-you-provided-method-name-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!