Repository navigation
Track whether Metadata has changed - #6
Merged
Merged
Conversation
Metadata::hasChanged() returns true once a call has altered the values or expiry times: set() of a new key, a different value or a moved expiry, remove()/unset() of an existing key, and dropping an expired key on any read that prunes. Constructing, reading live keys and jsonSerialize() are not changes, and the flag is never reset. set() now validates the TTL before storing anything, so a rejected call leaves the metadata as it was. Pruning still goes through the overridable remove(), because released setono/client-bundle versions override it to notice dropped keys. Closes #5
Rector 2.8 adds IfToNullCoalescingAssignRector, which fails the dry-run in the highest-dependencies Coding Standards job.
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
Metadata::hasChanged()returnstrueonce a call has actually altered the values or expiry times. Constructing never counts, and nothing resets it.Pruning in
has()/get()/ArrayAccessreads/count()/iteration/toArray()still goes through the overridableremove(), so dropping an expired key counts as a change. That routing is kept on purpose, and a test fixes it in place: released setono/client-bundle versions (^1.1.1) overrideremove()to notice dropped keys.The README's Metadata section has a new "Tracking changes" part listing what counts as a change.
Evidence
origin/master):Metadata. The 4 that escape are the knownClient.phpUUID match arms.Merge Danger
Door: two-way until 1.2.0 is tagged
After the tag,
hasChanged()is public API and the bundle will rely on it, so taking it out would be a BC break.Blast Radius: narrow
set()with a TTL of 0 or less no longer stores the value before throwing. Only code that catches that exception and then reads the key would notice.hasChanged()with a different signature would fatal. client-bundle'sChangeAwareMetadatausesisDirty(), so it doesn't clash.Closes #5