A lot of sources call a single resource, typically through <cfthread ..>, but some use <cfinclude ..>.
Ideally, the code looks for the variable previous_state. If some variants are passed, then the resource will attempt to use them.
I received this error:
Variable PREVIOUS_STATE is undefined.
The line record points to the <cfif ..> in this chunk of code.
<cfparam name= "previous_state"
default= "" />
<cfif isSimpleValue( previous_state )
and len( previous_state ) eq 0>
<cfset previous_state= previousState />
</cfif>
My question is how can previous_state be undefined?
I can duplicate it in the application, but it’s a fairly complex chain of code using threads. Perhaps the reference was eaten by the garbage collector?
I’m having trouble duplicating it in a simple code segment. I’ve tried setting the variable to the return of a function with returnType= "void", but <cfparam ..> seems to reset it to an empty string.
Here’s the full code context. I removed the unrelated vars and such.
// Page
oComponent.foo();
// Component.foo()
<cfset var local= {
previous_state= QueryNew( "foo" , "varchar" )
} />
<cfthread name= "foo_#createUUID()#"
previousState= "#local.previous_state#">
<!--- Module does unrelated things... --->
<cfmodule template= "some_module.cfm">
<cfoutput>
// unrelated things
<cfparam name= "previous_state"
default= "" />
<!--- Next line is throwing error. --->
<cfif isSimpleValue( previous_state )
and len( previous_state ) eq 0>
<cfset previous_state= previousState />
</cfif>
</cfoutput>
</cfmodule>
</cfthread>
I’m now thinking cfparam is trying to use a scope that no longer exists by the time this code executes.
As the code is within a CFTHREAD tag I thing you should be passing
previous_stateas a CFTHREAD attribute, such as:To quote the CF Docs:
“The Attributes scope contains attributes that are passed to the scope, and is available only within the thread and only for the life of the thread.”