mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 12:24:04 +00:00
Minor fixes
The change in SQLiteDatabaseManager wasn't properly saving the updated internal value. The check in CacheTenancyBootstrapper wasn't handling that local tests have a 'testing' environment, not local. However fixing only the condition would've still added the store to $names which would throw an exception down the line. We make sure to only throw the exception in prod, but also make sure to only add the store to $names if it is supported.
This commit is contained in:
parent
99b79a5d08
commit
aba7a50619
2 changed files with 13 additions and 12 deletions
|
|
@ -101,9 +101,8 @@ class CacheTenancyBootstrapper implements TenancyBootstrapper
|
||||||
|
|
||||||
if ($this->config->get('tenancy.cache.scope_sessions', true)) {
|
if ($this->config->get('tenancy.cache.scope_sessions', true)) {
|
||||||
// These are the only cache driven session backends (see Laravel's config/session.php)
|
// 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)
|
if (! in_array($this->config->get('session.driver'), ['redis', 'memcached', 'dynamodb', 'apc'], true)) {
|
||||||
&& ! app()->environment('local')
|
if (app()->environment('production')) {
|
||||||
) {
|
|
||||||
// We only throw this exception in prod to make configuration a little easier. Developers
|
// 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.
|
// 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
|
// Previously we just silently ignored this, however since session scoping is of high importance
|
||||||
|
|
@ -111,10 +110,11 @@ class CacheTenancyBootstrapper implements TenancyBootstrapper
|
||||||
// scoping isn't happening as expected/configured due to an incompatible session driver.
|
// scoping isn't happening as expected/configured due to an incompatible session driver.
|
||||||
throw new Exception('Session driver [' . $this->config->get('session.driver') . '] cannot be scoped by tenancy.cache.scope_session');
|
throw new Exception('Session driver [' . $this->config->get('session.driver') . '] cannot be scoped by tenancy.cache.scope_session');
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
// Scoping sessions using this bootstrapper implicitly adds the session store to $names
|
// Scoping sessions using this bootstrapper implicitly adds the session store to $names
|
||||||
$names[] = $this->getSessionCacheStoreName();
|
$names[] = $this->getSessionCacheStoreName();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$names = array_unique($names);
|
$names = array_unique($names);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ class SQLiteDatabaseManager implements TenantDatabaseManager
|
||||||
|
|
||||||
$name = '_tenancy_inmemory_' . $tenant->getTenantKey();
|
$name = '_tenancy_inmemory_' . $tenant->getTenantKey();
|
||||||
$tenant->setInternal('db_name', "file:$name?mode=memory&cache=shared");
|
$tenant->setInternal('db_name', "file:$name?mode=memory&cache=shared");
|
||||||
|
$tenant->save();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue