fix(di): flip injector hardener S2 S3 S7 - #3421
Merged
Merged
Conversation
Rebind resets singleton/request flags and drops request.$wheelsDICache. asSingleton/asRequestScoped throw Wheels.Injector when no mapping is in progress, and map(b).asSingleton().to(...) flags b. getMappings() returns a Duplicate copy. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Peter Amiri <peter@alurium.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Peter flipped injector HOLDs S2, S3, and S7. Rebind kept stale singleton/request flags and
request.$wheelsDICache.asSingleton/asRequestScopedwere silent no-ops whenlastMappedNamewas empty, andmap(b).asSingleton().to(...)flagged the previous key.getMappings()returned the live internal struct.This PR flips those three contracts in
Injector.cfcand updates the HOLD-pin specs so they assert the new behavior.Desk IDs stay S1–S10. S1/S4/S5/S6/S8/S9/S10 stay as already proven on develop. S4 stays dotted-path fallback.
Scope
vendor/wheels/Injector.cfc— production flipsvendor/wheels/tests/specs/injector/InjectorHardenerSpec.cfc— HOLD pins become the new contractchangelog.d/injector-hardener-s2-s3-s7.changed.mdOut: CLI Application.cfc injector, SQL-injection specs, docs/blog,
inject()in controller/services.cfc,$snapshotBindings/$restoreBindings,application.wheelsdiself-register.Exception types
Reuse
Wheels.Injector(same type asto()withoutmap(), and as S9 emptymap("")thento()).asSingleton()with no in-progressmap()and no completedto()throwsWheels.InjectorasRequestScoped()under the same empty state throwsWheels.InjectorNo new type.
Tradeoffs
Rebind reset lives in
map(), notto(). That letsmap(b).asSingleton().to(...)flagbafter the reset. Resetting into()would wipe the flag thatasSingletonjust set.getMappings()now returnsDuplicate(variables.mappings). Callers that mutated the old live struct to register aliases will no longer change the container.Dropping
request.$wheelsDICacheon rebind is the whole request cache, not one key. That is what the old HOLD pin asserted we never did.Desk S1–S10
getInstancecalls of the same mapping get distinct instances. Unchanged.request.$wheelsDICache. First bind of a new name does not drop the cache. Unrelated flags stay.asSingleton/asRequestScopedthrowWheels.InjectorwhenlastMappedNameandcurrentMappingare empty.map(b).asSingleton().to(...)flagsb, not the previous key.getInstanceis dotted-path fallback. Unchanged.Wheels.DI.CircularDependency. Unchanged.getMappings()returns aDuplicatecopy. Mutating it, or mapping later, does not change latergetMappings()orcontainsInstance.onDIcompleteonce per constructed instance. Unchanged.map("")thento()throwsWheels.Injector. Unchanged.Verification
Command actually run:
JSON from the same filter (
directory=wheels.tests.specs.injector):Also ran, not the driver:
Wheels CLI 4.0.6. Lucee 7.0.0.395. sqlite.
Adobe and BoxLang were not run here.
HEAD
a28a2814e982a3997eba0bf0b9343a69fcfb14e0Base
32aa26747e29b884a9970f77c100cd06b0055905(develop after injector hardener prove).Do not merge. Hive off merge.