1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-09-20 15:14:03 +00:00

Handle tenancy.cache.stores changes during revert

Also add a separate test ('scopeCache ignores changes to tenancy.cache.stores made in tenant context' ) -- the 'central cache is not lost when tenancy ends' covered the skipping mechanism partially, but having a separate test for the tenancy.cache.stores mid-tenant context changes is definitely cleaner and makes more sense.
This commit is contained in:
lukinovec 2026-08-04 18:21:21 +02:00
parent 597e48ec90
commit 8244e56618
2 changed files with 57 additions and 21 deletions

View file

@ -193,7 +193,14 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
return;
}
foreach ($this->app['config']['tenancy.cache.stores'] as $name) {
// On revert, restore exactly the stores captured during bootstrap -- not the current
// (possibly mutated) tenancy.cache.stores. Otherwise, removing a store from that
// config in tenant context would make revert() skip it (so the store would be stuck with a tenant-scoped path).
$stores = $suffix !== false
? $this->app['config']['tenancy.cache.stores']
: array_keys($this->originalCachePaths);
foreach ($stores as $name) {
$store = $this->app['config']["cache.stores.{$name}"];
// Only file stores have a path to scope. Skip stores that don't exist (null) or use another driver.