Skip to content

[14.x] Ensure Cache has & forget work for arrays - #61466

Merged
taylorotwell merged 4 commits into
laravel:masterfrom
jackbayliss:14.x-cache-has-and-forget-arrays
Sep 7, 2026
Merged

taylorotwell merged 4 commits into
laravel:masterfrom
jackbayliss:14.x-cache-has-and-forget-arrays

Conversation

@jackbayliss

@jackbayliss jackbayliss commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

This surprised me as has / forget report that it works for arrays:

image

But, if you do Cache::has(['some', 'thing']) even if it doesnt exist, it'll always return true, for anything.

Similar for forget, if you give it an array it won't actually forget the array.

Cache::forget(['item', 'item2']);

   WARNING  Array to string conversion in vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php on line 288.

This PR ensures they work as expected, ie forget with an array will forget them all.. and has ensures all the items exist. The same as get() and put() do basically.

Its been like it in the docblocks for 4 years since 732a29a so, I didn't go with pulling array out, as people may still use it.

Let me know if you would rather me pull the array doc or, whatever you see best! 🫡

I've targeted 14.x as folk may not realise this.. and dont fancy breaking apps

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Thanks for submitting a PR!

Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@jackbayliss
jackbayliss marked this pull request as ready for review September 7, 2026 13:04
@taylorotwell
taylorotwell merged commit 98149aa into laravel:master Sep 7, 2026
46 checks passed
@jackbayliss
jackbayliss deleted the 14.x-cache-has-and-forget-arrays branch September 7, 2026 20:12
binaryfire added a commit to hypervel/components that referenced this pull request Sep 28, 2026
Resolve associative, mixed and sparse input into the same key list used
by many(), without carrying default values into the existence check. Keep
repository events, enum handling, wrapper stores and cached-null semantics.

Extend the existing array-key test to cover defaults, false values and
cached nulls alongside sparse and mixed keys.

Follow-up to laravel/framework#61466.

Validated CacheRepositoryTest, the affected parallel test selection,
source and type analysis, and formatting.
binaryfire added a commit to hypervel/components-backup that referenced this pull request Oct 1, 2026
Check every requested key in has and delegate array removal to deleteMultiple. Keep enum-key normalization and existing tagged-cache restrictions, widen the repository contract consistently, and update generated facade annotations, tests and documentation.

Upstream: laravel/framework#61466

Framework source: 7068848dfe48fc3a433598e09ce798799d442a52.
Documentation source: laravel/docs 13.x at ec28ad6ee78ebeada6095e05d33da7e8c42dd6dc.

Validated with affected tests, repository formatting, full source and type-fixture analysis, and the full parallel test suite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants