Coldfusion,您提供的符号 [method_name] 不是函数
运行 CF 9,0,1,274733
我有一个自定义 DAO CFC,其方法名为 getGamesBetTypesID()。
该方法由 CF 从以下属性隐式生成/合成:
<cfproperty name="gamesBetTypesID" type="numeric" />
默认变量定义如下:
<cfset VARIABLES.gamesBetTypesID = 0 />
除此之外,没有其他变量、变量、本地、参数或称为 getGamesBetTypesID 的方法。所有 CFC 和函数变量的作用域均正确。
这个 save() 方法被调用了数千次,但以下错误只是随机抛出几次。
Detail: The symbol you provided getGamesBetTypesID is not the name of a function.
Message: Entity has incorrect type for being called as a function.
这是 save() 方法:
<cffunction name="save" access="public" returntype="void" output="false">
<cfif getGamesBetTypesID() eq 0 or getGamesBetTypesID() eq "">
<cfset create() />
<cfelse>
<cfset update() />
</cfif>
</cffunction>
当抛出错误时,我使用以下命令记录 CFC 元数据的转储 getMetaData(gamesBetTypesObj)。根据元数据,函数 getGamesBetTypesID 确实存在。
以前有其他人遇到过这个吗?我读到这可能是由于命名和范围冲突而发生的,但我没有。
提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
发布上述问题后,我删除了
并为VARIABLES.gamesBetTypesID
添加了显式 getter 和 setter。这段代码已经在生产环境中运行了一个星期,其中包括一个周末,这是我们忙碌的时期。过去 7 天内没有发生任何异常。此前,在繁忙的一天中最多会抛出 15 个异常。
这让我相信通过
生成/使用隐式访问器时存在一个错误,该错误仅出现在某些情况下。我将使用 Adobe 记录错误,如果取得任何进展。
After posting the question above I removed
<cfproperty name="gamesBetTypesID" type="numeric" />
and added an explicit getter and setter forVARIABLES.gamesBetTypesID
.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 AdobeI'll update if any progress is made.
更新一个很老的问题。我遇到了同样的情况,但我的函数被明确命名(没有 cfproperty 或 get/set)。问题是我在函数中使用与函数相同的名称声明了一个局部变量。我的函数是从循环内调用的。如果该函数仅被调用一次,则没有问题。如果第二次调用该函数,我将收到与您收到的相同错误。我怀疑当创建局部变量时,由于命名冲突,它会清除函数定义。我重命名了局部变量,问题就消失了。
Updating a very old question. I had the same situation pop up but my function was explicitly named (no cfproperty or get/set). The issue was that I had a local variable declared within my function using the same name as my function. My function was called from within a loop. If the function was only called once, no issue. If the function was called a second time, I would receive the same error you received. I suspect when the local variable was created it would wipe out the function definition due to the naming collision. I renamed my local variable and the issue disappeared.