Yesterday I did a bit of an investigation in to how ColdFusion looks for an Application.cfc / .cfm when it runs a request. This article is a continuation of that, and it won't make any sense if you don't read yesterday's article first.
In yesterday's article I had this directory structure set up:
C:\
apps\
adobe\
ColdFusion\
10\
cfusion\
wwwroot\
docroot\
test.cfm
some_dir\
linked_subdir\
test.cfm
local_subdir\
test.cfm
temp\
linked_subdir\
test.cfm
And I covered the look-ups for Application.cfc from both local directories, and junctioned / linked directories.
Following my Twitter feed this evening, and Laura Springer (who I don't know, other than from following on Twitter: I hope you don't mind me using you as an inspiration, Laura) made an observation about Application.cfc file behaviour when called from a virtual directory.
And it occurred to me that this is:
- something I didn't cover in my previous article;
- another thing I didn't know the behaviour of.
C:\
apps\
adobe\
ColdFusion\
10\
cfusion\
wwwroot\
docroot\
test.cfm
some_dir\
linked_subdir\
test.cfm
local_subdir\
test.cfm
virtual_subdir\
test.cfm
temp\
linked_subdir\
test.cfm
virtual_subdir\
test.cfm
Where C:\temp\virtual_subdir is a physical directory mapped into the site via a virtual directory /some_dir/virtual_subdir/.
I'll not do all the colour-coding and stuff from last night, but when browsing to /some_dir/virtual_subdir/test.cfm, ColdFusion looks for Application.cfc / .cfm files in the directories as listed below:
Default
C:\temp\virtual_subdir\Application.cfcC:\temp\Application.cfc
C:\Application.cfc
Until Webroot
C:\temp\virtual_subdir\Application.cfcC:\temp\Application.cfc
C:\Application.cfc
In Webroot
C:\temp\virtual_subdir\Application.cfcC:\apps\adobe\ColdFusion\10\cfusion\wwwroot\docroot\Application.cfc
So as you can see here: for the first two options it looks up in the physical directory structure, but in the latter example it looks in the immediate physical directory, and then looks in the web site's web root (and no further).
Another curious thing... you know how yesterday I said that the "web root" for the purposes of this look-up meant "the ColdFusion root", not the web server / site's web root? I tested that assertion three times last night, and was 100% confident I was correct in saying that (I checked because it seemed to be contradicting what I was reading elsewhere on the 'net, so presumed initially I was wrong). However this evening having seen what seemed like anomalous behaviour with that last path on the "in webroot" look-up, I tested again. And for the life of me I cannot replicate last night's behaviour this evening: this evening "web root" means "the web site's web root" not "ColdFusion's application root". There's a chance I screwed up last night, but I really don't think I did. Well: 80% sure I didn't. However I could have got something wrong. I'm gonna put a caveat on last night's article until I test more thoroughly, and make myself sure of what's what.
That's all I have to say on that. I had better go put a warning on y/day's article to the effect that I might be talking ballocks. Well: more so than usual, I mean ;-)
--
Adam