Repository navigation
Conversation
sk4rp
force-pushed
the
fix-cache-key-boolean-null-args
branch
from
October 24, 2026 16:37
a55b992 to
6d88fd2
Compare
Comment on lines
40
to
42
| $parts[] = is_array($value) || is_bool($value) || $value === null | ||
| ? \Safe\json_encode($value) | ||
| : $value; |
Author
There was a problem hiding this comment.
@spawnia fixed in b84a06a.
All non-object argument values are now JSON encoded, so strings are quoted (arg:"null") and can no longer collide with null, booleans, numbers or arrays.
Objects are still cast through __toString() as before.
Added regression tests for null vs "null" on the key generator and on a @cache field.
sk4rp
force-pushed
the
fix-cache-key-boolean-null-args
branch
from
October 25, 2026 16:23
6d88fd2 to
b84a06a
Compare
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.

Changes
CacheKeyAndTagsGenerator::key()joined argument values withimplode(), which stringifiesfalseandnullto''andtrueto'1'.As a result,
foo(flag: false)andfoo(flag: null)shared one cache entry, so@cachecould return the result of a different argument value.All non-object argument values are now JSON encoded, so each value keeps its type in the key:
arg:null,arg:false,arg:true,arg:"null",arg:5,arg:[1,2].Strings are quoted, so they no longer collide with
null, booleans, numbers or arrays, and colons inside string values can no longer be confused with the key separator.Objects are still stringified through
__toString()as before.Breaking changes
None. Keys for integer and array arguments are unchanged.
Cache entries for fields with string, boolean or
nullarguments get new keys, so they are recomputed once after upgrading.Changelog
Fixed
@cachekeys, sonull, booleans and strings no longer share cache entries