Description
The Application.cfc generated by wheels new declares a local injector variable in onApplicationStart() but then attempts to use application.wheelsdi — which is never assigned. Since application.wheelsdi is the public 4.0 DI container (replacing the 3.x application.wirebox), the local variable should be assigned to it.
Reproduction
wheels new test-app --datasource=test --reload-password=PLACEHOLDER
cat test-app/public/Application.cfc
The generated onApplicationStart():
function onApplicationStart() {
application.env = duplicate(this.env);
injector = new wheels.Injector("wheels.Bindings");
/* wheels/global object */
application.wo = injector.getInstance("global");
initArgs.path="wheels";
initArgs.filename="onapplicationstart";
application.wheelsdi.getInstance(name = "wheels.events.onapplicationstart", initArguments = initArgs).$init(this);
}
application.wheelsdi is never assigned. On first request, the last line throws because the application-scoped reference is undefined.
Impact
Every new application scaffolded by wheels new fails to boot until the user manually patches Application.cfc. Since this is also a framework boilerplate file that applications shouldn't customize, that's an uncomfortable workaround.
Suggested Fix
Assign the injector to application.wheelsdi so it matches the documented 4.0 DI container name and is available throughout the application:
function onApplicationStart() {
application.env = duplicate(this.env);
application.wheelsdi = new wheels.Injector("wheels.Bindings");
/* wheels/global object */
application.wo = application.wheelsdi.getInstance("global");
initArgs.path="wheels";
initArgs.filename="onapplicationstart";
application.wheelsdi.getInstance(name = "wheels.events.onapplicationstart", initArguments = initArgs).$init(this);
}
This is consistent with the 4.0 migration path (application.wirebox → application.wheelsdi) documented in the 4.0 release audit.
Environment
- Wheels CLI: 4.0.0 (stable,
brew install wheels)
- Scaffold command:
wheels new <name> --datasource=<ds> --reload-password=<pw>
Description
The
Application.cfcgenerated bywheels newdeclares a localinjectorvariable inonApplicationStart()but then attempts to useapplication.wheelsdi— which is never assigned. Sinceapplication.wheelsdiis the public 4.0 DI container (replacing the 3.xapplication.wirebox), the local variable should be assigned to it.Reproduction
The generated
onApplicationStart():function onApplicationStart() { application.env = duplicate(this.env); injector = new wheels.Injector("wheels.Bindings"); /* wheels/global object */ application.wo = injector.getInstance("global"); initArgs.path="wheels"; initArgs.filename="onapplicationstart"; application.wheelsdi.getInstance(name = "wheels.events.onapplicationstart", initArguments = initArgs).$init(this); }application.wheelsdiis never assigned. On first request, the last line throws because the application-scoped reference is undefined.Impact
Every new application scaffolded by
wheels newfails to boot until the user manually patchesApplication.cfc. Since this is also a framework boilerplate file that applications shouldn't customize, that's an uncomfortable workaround.Suggested Fix
Assign the injector to
application.wheelsdiso it matches the documented 4.0 DI container name and is available throughout the application:function onApplicationStart() { application.env = duplicate(this.env); application.wheelsdi = new wheels.Injector("wheels.Bindings"); /* wheels/global object */ application.wo = application.wheelsdi.getInstance("global"); initArgs.path="wheels"; initArgs.filename="onapplicationstart"; application.wheelsdi.getInstance(name = "wheels.events.onapplicationstart", initArguments = initArgs).$init(this); }This is consistent with the 4.0 migration path (
application.wirebox→application.wheelsdi) documented in the 4.0 release audit.Environment
brew install wheels)wheels new <name> --datasource=<ds> --reload-password=<pw>