Search code examples
coldfusioncomponents

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


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.


Solution

  • 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.