@@ -99,10 +99,20 @@ protected function getCacheStores(): array
9999 {
100100 $ names = $ this ->config ->get ('tenancy.cache.stores ' );
101101
102- if (
103- $ this ->config ->get ('tenancy.cache.scope_sessions ' , true ) &&
104- in_array ($ this ->config ->get ('session.driver ' ), ['redis ' , 'memcached ' , 'dynamodb ' , 'apc ' ], true )
105- ) {
102+ if ($ this ->config ->get ('tenancy.cache.scope_sessions ' , true )) {
103+ // These are the only cache driven session backends (see Laravel's config/session.php)
104+ if (! in_array ($ this ->config ->get ('session.driver ' ), ['redis ' , 'memcached ' , 'dynamodb ' , 'apc ' ], true )
105+ && ! app ()->environment ('local ' )
106+ ) {
107+ // We only throw this exception in prod to make configuration a little easier. Developers
108+ // may have scope_sessions set to true while using different session drivers e.g. in tests.
109+ // Previously we just silently ignored this, however since session scoping is of high importance
110+ // in production, we make sure to notify the developer, by throwing an exception, that session
111+ // scoping isn't happening as expected/configured due to an incompatible session driver.
112+ throw new Exception ('Session driver [ ' . $ name . '] cannot be scoped by tenancy.cache.scope_session ' );
113+ }
114+
115+ // Scoping sessions using this bootstrapper implicitly adds the session store to $names
106116 $ names [] = $ this ->getSessionCacheStoreName ();
107117 }
108118
@@ -112,6 +122,7 @@ protected function getCacheStores(): array
112122 $ store = $ this ->config ->get ("cache.stores. {$ name }" );
113123
114124 if ($ store === null || $ store ['driver ' ] === 'file ' ) {
125+ // 'file' stores are ignored here and instead handled by FilesystemTenancyBootstrapper
115126 return false ;
116127 }
117128
0 commit comments