Status/Resolution/Reason: Closed/Fixed/Fixed
Reporter/Name(from Bugbase): Thomas Rafferty / ()
Created: 10/08/2018
Components: Language, CF Component
Versions: 2016,11.0,2018
Failure Type: Others
Found In Build/Fixed In Build: 11,0,12,302575 / CF2016U12,CF2018U5
Priority/Frequency: Normal /
Locale/System: / Windows 10 64 bit
Vote Count: 1
Problem Description:
The error message "Routines cannot be declared more than once" is being shown for a function that is included twice with runonce="true" specified both times.
This problem does not occur using Lucee.
Steps to Reproduce:
Here is a short test case of 4 files that reproduces the problem.
{code:java}
<!--- /index.cfm --->
<cfset createObject("component", "component").init()>
<!--- /component.cfc --->
<cfcomponent>
<cffunction name="init" output="true">
<cfinclude template="file_that_depends_on_message.cfm" runonce="true">
<cfinclude template="message.cfm" runonce="true">
<cfset message("component")>
</cffunction>
</cfcomponent>
<!--- /file_that_depends_on_message.cfm --->
<cfinclude template="message.cfm" runonce="true">
<cfset message("file that depends on message")>
<!--- /message.cfm --->
<cffunction name="message" output="true">
<cfargument name="value" type="string">
<cfoutput>#value#<br></cfoutput>
</cffunction>
{code}
Actual Result:
The error message "Routines cannot be declared more than once."
Expected Result:
"file that depends on message
component"
Any Workarounds:
Using cfscript, the function can be defined anonymously and assigned to a variable.
Example:
<cfscript>
variables.message = function(value)
{ writeOutput("#value#<br>"); }
;
</cfscript>
Attachments:
Comments: