mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #9627 from creative-commoners/pulls/4.6/try-catch-config-db-paths
FIX Handle DatabaseAdapterRegistry cache exception
This commit is contained in:
commit
e368c370ff
@ -164,9 +164,17 @@ class DatabaseAdapterRegistry implements Flushable
|
|||||||
if (isset($_GET['flush'])) {
|
if (isset($_GET['flush'])) {
|
||||||
static::flush();
|
static::flush();
|
||||||
}
|
}
|
||||||
$cache = static::getCache();
|
try {
|
||||||
|
$cache = static::getCache();
|
||||||
|
} catch (\LogicException $e) {
|
||||||
|
// This try/catch statement is here rather than in getCache() for semver
|
||||||
|
// A LogicException may be thrown from `Symfony\Component\Finder\Finder::getIterator()`
|
||||||
|
// if the config manifest is empty. There are some edge cases where this can happen, for instance
|
||||||
|
// running `sspak save` on a fresh install without ?flush
|
||||||
|
$cache = null;
|
||||||
|
}
|
||||||
$key = __FUNCTION__;
|
$key = __FUNCTION__;
|
||||||
if ($cache->has($key)) {
|
if ($cache && $cache->has($key)) {
|
||||||
return (array) $cache->get($key);
|
return (array) $cache->get($key);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@ -174,11 +182,16 @@ class DatabaseAdapterRegistry implements Flushable
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$paths = [];
|
$paths = [];
|
||||||
}
|
}
|
||||||
$cache->set($key, $paths);
|
if ($cache) {
|
||||||
|
$cache->set($key, $paths);
|
||||||
|
}
|
||||||
return $paths;
|
return $paths;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return CacheInterface
|
||||||
|
*/
|
||||||
public static function getCache(): CacheInterface
|
public static function getCache(): CacheInterface
|
||||||
{
|
{
|
||||||
return Injector::inst()->get(CacheInterface::class . '.DatabaseAdapterRegistry');
|
return Injector::inst()->get(CacheInterface::class . '.DatabaseAdapterRegistry');
|
||||||
|
Loading…
Reference in New Issue
Block a user