Repository navigation
Add a runtime override layer for one request or job - #22
Merged
Merged
Conversation
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.
Summary
Adds a runtime override layer: an in-memory value for a setting that lasts one request or job. It wins over every stored layer, and it is never written, cached, versioned, audited or encrypted.
API (on the contract,
SettingsManager,SettingsFakeand the facade):override(string|array $key, $value = null)forgetOverride($key)hasOverride($key)clearOverrides()withOverrides(array, callable): restores the previous overrides infinally, including when the callback throws, and nests.Design:
#[Scoped]Services\Resolution\Overrides, so overrides end with the request or job, under Octane too. It is keyed by store, scope, key and locale, and split per tenant.Resolverchecks overrides first, along the same owner → parents → global walk. With no overrides held, the lookup path, the queries and the behaviour are all unchanged.ValuePipeline::inMemory(), includingvalues.max_bytes.file/configprecedence, by design; this is documented.viewandview_sensitive.explain()reports the layeroverride, andlaranail::settings.showadds anOverriderow.save()skips a property whose value came from an override, unless it changed.Docs
docs/tools/runtime-overrides.md: a full reference.docs/recipes/overriding-a-setting-for-one-request.md: middleware, a queued job, and a feature-flag switch.Verification (local)
finallyfromwithOverrides, and binding the overrides store as a singleton.