主站点子目录中的测试站点引用了错误的 Application.cfc

发布于 2024-09-19 12:27:32 字数 1027 浏览 4 评论 0原文

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

在生产站点的子目录中,我有一个包含该站点的测试版本的文件夹。它有自己的 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>

这最初看起来工作正常。如果我们将“?reset”添加到测试版本上任何页面的 url,Application.cfc 所做的更改会立即反映出来,但我们很快发现了一个令人讨厌的副作用:在测试版本上调用重置也会更改我们的生产站点以使用Application.cfc 的测试版本,从而极大地破坏了一切。

在生产站点上运行“?重置”逻辑修复了此问题,但随后导致所有测试页面使用生产 Application.cfc 而不是测试版本。等待Application.cfcs超时并自动刷新没有什么区别,所以现在我们的测试环境一团糟。

任何对正在发生的事情或该怎么做的见解都将不胜感激,因为我们相当困惑。这只是一个糟糕的架构吗?我们继承了它,现在已经非常习惯这种结构,因此首选快速修复,但我愿意接受建议。

谢谢。

I have a CF9 project set up with a multi-tiered directory structure. At the root level I have the live production site with its Application.cfc. It contains a number of variables that are bound to a 'debugMode' flag--so in the case of the production site, this flag is set to false.

In a subdirectory of the production site, I have a folder containing a testing version of the site. This has its own Application.cfc with debugMode set to true. Other than this flag and changes that we are testing, it's identical to the production Application.cfc.

There haven't been any problems with this UNTIL we added logic for resetting Application.cfc in order to see our changes without waiting for the timeout (which we have set to 30 minutes).

To accomplish this, we added this block to the 'OnRequestStart' function in Application.cfc (it is present on both production and testing versions):

    <cfif StructKeyExists( URL, "reset" )>

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

    </cfif>

This initially appeared to work fine. If we add '?reset' to the url for any page on the testing version, changes made Application.cfc are reflected immediately, but we quickly discovered a nasty side effect: calling reset on the testing version ALSO changes our production site to use the testing version of Application.cfc, thereby mightily fubaring everything.

Running the '?reset' logic on the production site fixed this problem, but then caused all the testing pages to use the production Application.cfc instead of the testing version. Waiting for the Application.cfcs to time out and refresh automatically made no difference, so now our test environment is messed up.

Any insight into what's going on or what to do would be greatly appreciated as we are fairly stumped. Is this simply a poor architecture? We inherited it and are now quite accustomed to this structure, so so a quick fix would be preferred, but I'm open to suggestions.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

左耳近心 2024-09-26 12:27:32

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

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

因此,无论您从“测试”站点还是“实时”站点触发刷新,它都会重置同一应用程序,然后从您发出重置的任何版本重新实例化变量。

您需要将“测试”应用程序的应用程序名称设置为与实时应用程序不同的名称。

对于测试:

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

对于直播:

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

The issue is most likely that the two application.cfc files specify the same application name.

So, they are, in essence, the same application.

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">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文