mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 12:44:02 +00:00
Session scoping (cache bootstrapper): throw on incompatible driver
This commit is contained in:
parent
ddf83c4b55
commit
74634dfe4b
1 changed files with 15 additions and 4 deletions
|
|
@ -99,10 +99,20 @@ class CacheTenancyBootstrapper implements TenancyBootstrapper
|
|||
{
|
||||
$names = $this->config->get('tenancy.cache.stores');
|
||||
|
||||
if (
|
||||
$this->config->get('tenancy.cache.scope_sessions', true) &&
|
||||
in_array($this->config->get('session.driver'), ['redis', 'memcached', 'dynamodb', 'apc'], true)
|
||||
if ($this->config->get('tenancy.cache.scope_sessions', true)) {
|
||||
// These are the only cache driven session backends (see Laravel's config/session.php)
|
||||
if (! in_array($this->config->get('session.driver'), ['redis', 'memcached', 'dynamodb', 'apc'], true)
|
||||
&& ! app()->environment('local')
|
||||
) {
|
||||
// We only throw this exception in prod to make configuration a little easier. Developers
|
||||
// may have scope_sessions set to true while using different session drivers e.g. in tests.
|
||||
// Previously we just silently ignored this, however since session scoping is of high importance
|
||||
// in production, we make sure to notify the developer, by throwing an exception, that session
|
||||
// scoping isn't happening as expected/configured due to an incompatible session driver.
|
||||
throw new Exception('Session driver [' . $name . '] cannot be scoped by tenancy.cache.scope_session');
|
||||
}
|
||||
|
||||
// Scoping sessions using this bootstrapper implicitly adds the session store to $names
|
||||
$names[] = $this->getSessionCacheStoreName();
|
||||
}
|
||||
|
||||
|
|
@ -112,6 +122,7 @@ class CacheTenancyBootstrapper implements TenancyBootstrapper
|
|||
$store = $this->config->get("cache.stores.{$name}");
|
||||
|
||||
if ($store === null || $store['driver'] === 'file') {
|
||||
// 'file' stores are ignored here and instead handled by FilesystemTenancyBootstrapper
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue