[13.x] Fix default handling in CookieJar::queued() - #60904
Merged
taylorotwell merged 1 commit intoJul 27, 2026
Conversation
alies-dev
marked this pull request as draft
July 27, 2026 13:31
alies-dev
force-pushed
the
fix/cookie-jar-queued-default
branch
from
July 27, 2026 13:36
ed59c99 to
ef96253
Compare
alies-dev
marked this pull request as ready for review
July 27, 2026 13:43
queued() passed $default as the fallback for the Arr::get() lookup and then re-processed that same value as if it were the array<path, Cookie> bucket, so a caller supplied default was fed back into Arr::last()/Arr::get(). Returning a Cookie default gave back bool(false), returning a scalar default threw a TypeError, and a Closure default was resolved twice. Cookie names and paths are now looked up as literal array keys. Passing them through Arr::get() dot notation meant a name such as "foo.bar" resolved to the cookie queued for the name "foo" at the path "bar", which also let $queued hold a Cookie instead of a bucket and reach Arr::last() as a non array.
alies-dev
force-pushed
the
fix/cookie-jar-queued-default
branch
from
July 27, 2026 13:51
ef96253 to
3857c29
Compare
CookieJar::queued()
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.
CookieJar::queued()uses$defaultfor two different jobs. It is the fallback for theArr::get()lookup, and then whatever that lookup returned is treated as the queue bucket:$this->queuedisarray<name, array<path, Cookie>>, so when the name is not queued the caller's default goes straight intoArr::last()as if it were a bucket of cookies. On13.xtoday, with #60887 already applied:The
bool(false)isCookie::$partitioned, the last property left afterArr::from()casts the object with(array). The scalar andClosurecases still throwItems cannot be represented by a scalar value., because #60887 guardedArr::last()againstnullonly andArr::from()rejects every other scalar. AClosuredefault is also resolved twice when$pathis passed, since bothArr::get()calls runvalue()on it.Only a
nulldefault ever worked, which is why nobody hit this.hasQueued()passesnull, and so does every first-party caller. That case broke too in v13.22.0 and #60887 fixed it, but every other default is still broken on 13.x today. This PR fixes thequeued()bug underneath, soCookieJarno longer depends on that guard.Both lookups also go through
Arr::get(), which falls back to segment traversal when the exact key is missing. Cookie names and paths are opaque strings, not key paths:That is also how
$queuedcan hold aCookieinstead of a bucket and reachArr::last()as a non-array. Both levels now read literal keys, and$defaultis resolved once, in one place.A cookie whose name really does contain a dot is unaffected.
Arr::get()checks the exact key before it splits on dots, soqueued('foo.bar')already returned the cookie queued under the literal namefoo.barand still does. Only the accidental traversal fallback goes away, andtestQueuedFindsCookieNamesContainingDotslocks that in.Docblocks:
@returnbecomesCookie|TQueuedDefault, since the method has always returned whatever$defaultwas while documentingCookie|null.@varon$queuedbecomesarray<string, array<string, Cookie>>; the currentCookie[]describes a flat shape the property has not had since paths were added.Compatibility
Nothing that previously returned a usable value changes. With a
nulldefault every branch returns exactly what it returned before. Any other default previously produced a wrong value or threw.