Skip to content

[12.x] Remove unnecessary forgetDriver()from TestCaches#58878

Merged
taylorotwell merged 5 commits intolaravel:12.xfrom
jackbayliss:12.x-cache-test-forget-issue
Feb 16, 2026
Merged

[12.x] Remove unnecessary forgetDriver()from TestCaches#58878
taylorotwell merged 5 commits intolaravel:12.xfrom
jackbayliss:12.x-cache-test-forget-issue

Conversation

@jackbayliss
Copy link
Contributor

@jackbayliss jackbayliss commented Feb 16, 2026

forgetDriver() destroys the resolved store, but classes like the RateLimiter retain a reference to the old instance. This means Cache::clear() clears a new store while the RateLimiter is still counting against the old one.

This breaks parallel tests when you clear the cache to reset rate limiters ie the clear essentially does nothing.

The only reason I can think for why this was here is if a cache store was already resolved by another provider — but in that case, forgetting it only makes things worse I guess?

Not sure if it's a B/C ie I couldnt think of a reason, but maybe you can - in which case we can do something like... (rather than just forgetting it blind)

    if ($this->app->resolved('cache')) {
        $store = $this->app['cache']->driver()->getStore();

        if (method_exists($store, 'setPrefix')) {
            $store->setPrefix($prefix);
        }
    }
    

All existing tests still pass and added a regression test to prevent this from being reintroduced.

This closes #58863 if merged :)

@jackbayliss jackbayliss changed the title Remove unnecessary forgetDriver()from TestCaches [12.x] Remove unnecessary forgetDriver()from TestCaches Feb 16, 2026
@github-actions
Copy link

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 February 16, 2026 22:39
@taylorotwell taylorotwell merged commit f9a2f15 into laravel:12.x Feb 16, 2026
72 checks passed
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.

Default cache driver (array) not working with parallel testing

2 participants

Comments