2

我有一个设置了多层目录结构的 CF9 项目。在根级别,我拥有带有 Application.cfc 的实时生产站点。它包含许多绑定到“debugMode”标志的变量——所以在生产站点的情况下,这个标志设置为假。

在生产站点的子目录中,我有一个文件夹,其中包含该站点的测试版本。这有自己的 Application.cfc,其中 debugMode 设置为 true。除了我们正在测试的这个标志和更改之外,它与生产 Application.cfc 相同。

这个没有任何问题,直到我们添加了重置 Application.cfc 的逻辑,以便在不等待超时(我们设置为 30 分钟)的情况下查看我们的更改。

为了实现这一点,我们将此块添加到 Application.cfc 中的“OnRequestStart”函数中(它存在于生产和测试版本中):

    <cfif StructKeyExists( URL, "reset" )>

        <!--- Reset application and session. --->
        <cfset THIS.OnApplicationStart() />
        <cfset THIS.OnSessionStart() />

    </cfif>

这最初似乎工作正常。如果我们在测试版本的任何页面的 url 中添加“?reset”,对 Application.cfc 所做的更改会立即反映,但我们很快发现了一个令人讨厌的副作用:在测试版本上调用 reset ALSO 会更改我们的生产站点以使用Application.cfc 的测试版本,从而使一切变得强大。

在生产站点上运行“?reset”逻辑解决了这个问题,但随后导致所有测试页面使用生产 Application.cfc 而不是测试版本。等待 Application.cfcs 超时并自动刷新没有任何区别,所以现在我们的测试环境搞砸了。

任何对正在发生的事情或做什么的见解将不胜感激,因为我们相当难过。这仅仅是一个糟糕的架构吗?我们继承了它,现在已经习惯了这种结构,所以最好快速修复,但我愿意接受建议。

谢谢。

4

1 回答 1

7

问题很可能是两个 application.cfc 文件指定了相同的应用程序名称。

因此,它们本质上是相同的应用程序。

So, whether you trigger the refresh from the "Test" site or the "Live" site, its resetting the same application, then re-instantiating the variables from whatever version you issued the reset from.

You need to set the application name for the "Test" application to something different then the live application.

For Test:

<!--- For the "Test" Application --->
<cfset this.name = "TESTApplication">

For Live:

<!--- For the "Live" Application --->
<cfset this.name = "Application">
于 2010-09-10T19:02:29.220 回答