While porting a large legacy application from ACF to Lucee, I encountered the following:
The app sets application specific mappings not in the Application.cfc
pseudo constructor, but in onRequestStart()
instead.
As usual, we use the mapping to e.g. instantiate CFCs: myCFC = new mapped-path.MyCFC();
This generally works, unless you use expandPath('/some-path-starting-with-slash')
in the request before setting the mappings.
e.g. the following will work:
this.mappings[ 'module' ] = getDirectoryFromPath( getCurrentTemplatePath() ) & 'moduleDir';
var whatever = expandPath( '/anotherDirectory' );
include arguments.targetPage;
}```
while this won't:
```public void function onRequest( required string targetPage ){
var whatever = expandPath( '/anotherDirectory' );
this.mappings[ 'module' ] = getDirectoryFromPath( getCurrentTemplatePath() ) & 'moduleDir';
include arguments.targetPage;
}```
If you use `expandPath()` with an argument that starts with a `/` somewhere in the request life cycle **before** setting the mappings, in the remaining request, Lucee can't find the path for that mapping.
Unfortunately I had already created an issue for this before I noticed the hint to first post it here on the mailing list. Sorry for disregarding order in which this should happen! The issue I created is https://luceeserver.atlassian.net/browse/LDEV-4031