우리는 다음과 같은 우리의 Application.cfc 코드가 : 우리가이 코드를 (내가 그것을 작성하지 않은)이있는 error.cfm 페이지 내에서ColdFusion에서 "루틴이 두 번 이상 선언 할 수 없습니다"
<cffunction name="onError" returnType="void" output="false">
<cfargument name="exception" required="true">
<cfargument name="eventname" type="string" required="true">
<cfset cfcatch = exception>
<cfinclude template="standalone/errors/error.cfm">
</cffunction>
를 :
<cfscript>
function GetCurrentURL() {
var theURL = "http";
if (cgi.https EQ "on") theURL = "#TheURL#s";
theURL = theURL & "://#cgi.server_name#";
if(cgi.server_port neq 80) theURL = theURL & ":#cgi.server_port#";
theURL = theURL & "#cgi.path_info#";
if(len(cgi.query_string)) theURL = theURL & "?#cgi.query_string#";
return theURL;
}
</cfscript>
이것은 모두 오류에 대한 세부 정보를 모아 데이터베이스에 기록하는 스크립트의 일부입니다.
오류가 발생하면 "루틴 GetCurrentURL이 다른 템플릿에서 두 번 선언되었습니다."라는 메시지가 나타납니다. 그러나 나는 여러 가지 방법으로 전체 코드베이스를 검색했으며 "GetCurrentURL"은 error.cfm에서 두 번만 사용된다는 것을 발견했습니다. 처음은 선언이고, 두 번째는 실제 사용입니다. 그래서 왜 CF가 "다른 템플릿에서"말하는지 잘 모르겠습니다.
나의 다음 생각은 문제가 재귀 호출하고, 그 error.cfm이 erroring 자체를 호출된다, 그래서이 문제를 해결해야 하나있는이 두 가지 변화를 시도하고 실제 오류 폭로 :
를<cfif StructKeyExists(variables,"GetCurrentURL") IS "NO">
<cfscript>
function GetCurrentURL() {
var theURL = "http";
if (cgi.https EQ "on") theURL = "#TheURL#s";
theURL = theURL & "://#cgi.server_name#";
if(cgi.server_port neq 80) theURL = theURL & ":#cgi.server_port#";
theURL = theURL & "#cgi.path_info#";
if(len(cgi.query_string)) theURL = theURL & "?#cgi.query_string#";
return theURL;
}
</cfscript>
</cfif>
그리고 :
<cfscript>
if (!StructKeyExists(variables,"GetCurrentURL")) {
function GetCurrentURL() {
var theURL = "http";
if (cgi.https EQ "on") theURL = "#TheURL#s";
theURL = theURL & "://#cgi.server_name#";
if(cgi.server_port neq 80) theURL = theURL & ":#cgi.server_port#";
theURL = theURL & "#cgi.path_info#";
if(len(cgi.query_string)) theURL = theURL & "?#cgi.query_string#";
return theURL;
}
}
</cfscript>
을 어느했다. 함수 호출 바로 전에이 페이지를 추가하려고 시도했습니다.
"YES"라는 단어가 화면에 인쇄되었습니다. 이것은 if 문의 내용이 "YES"로 평가되므로 if 문이 false로 평가되어 함수가 선언되지 않으므로 위의 내용이 작동 함을 나타냅니다. 따라서 제 정신을 유지할 것입니다. 그러나 어떤 이유로이 문제는 계속 발생합니다.
어떤 문제가 발생했는지 또는 다음 문제를 해결하는 방법에 대한 의견이 있으십니까? 나는이 시점에서 붙어있다.
error.cfm이 elswhere에 포함되어 있지 않은 것은 확실합니까? onError()에만 포함됩니까? –
예, onError()에서만 사용되었습니다. – Nicholas