For example, I have a page. I can load this page 100 times without error. However sometimes someone gets an error because I get the email that is sent from ColdFusion in the onError method. I don’t get them a lot, but I get them more than I would think I should. It’s impossible to “debug” because it doesn’t happen all the time. Once a day maybe on a given page.
Has anyone seen anything similar.
One exmaple:
if((StructKeyExists(ARGUMENTS.itm, 'video_code') && len(trim(ARGUMENTS.itm.video_code)) || !StructKeyExists(ARGUMENTS.itm, 'video_code')) == 0) return '<a #class# #target# #linkid# #pageid# href="#url#">#title##fileext#</a>';
else return '<a class="youtube_video" #target# #linkid# href="http://www.youtube.com/v/#itm.video_code#?version=3&autoplay=1&rel=0&modestbranding=1">#title#</a>';
In this page request, the item struct had video_code in there. But when the second line was processed video_code was undefined. I can run the page 100 more times, and this doesn’t happen.
objectType class coldfusion.runtime.Struct
element VIDEO_CODE
Resolvedname ITM
Detail
ErrNumber 0
Message Element VIDEO_CODE is undefined in ITM.
Type Expression
Trace: Template Line
D:\www\websites\assets\cfcs\menu.cfc 240
D:\www\websites\assets\cfcs\menu.cfc 209
D:\www\websites\assets\cfcs\menu.cfc 15
D:\www\websites\assets\templates\distance_general\campus_index_page.cfm 120
D:\www\websites\domain.com\index.cfm 1
It’s a bug in your code.
That’s the standard automatic response when anyone asks a question like the one you have, because it’s almost always the case.
There is of course a chance that you’ve identified a flaw in ColdFusion, but the odds of finding a bug in an established product are significantly lower than those of it being an error in your specific code/config.
Given the convoluted code provided as an example, the probably is very high that it’s a bug in your code.
Simply, no. There are no parse-level constructs that would make the parser behave differently, and the parsing is done once, then the same compiled code is used (until cleared or server restarted).
Looking again at the example, it may well be a scoping issue – you are checking StructKeyExists on
ARGUMENTS.itmbut are then using simplyitmin the code. ColdFusion has threading issues with unscoped variables that can manifest when under heavy load.Use varscoper to check for unscoped variables.