1
0
Fork 0
mirror of synced 2024-07-04 14:10:33 +12:00

refill pools on exception

This commit is contained in:
Damodar Lohani 2022-10-23 08:19:10 +00:00
parent 084b4e8c08
commit adf3f74ef2

View file

@ -47,11 +47,20 @@ function getConsoleDB(): Database
$pools = $register->get('pools'); /** @var \Utopia\Pools\Group $pools */
$dbAdapter = $pools
->get('console')
->pop()
->getResource()
;
try {
$dbAdapter = $pools
->get('console')
->pop()
->getResource()
;
} catch (Throwable $error) {
$pools->fill();
$dbAdapter = $pools
->get('console')
->pop()
->getResource()
;
}
$database = new Database($dbAdapter, getCache());
@ -71,11 +80,20 @@ function getProjectDB(Document $project): Database
return getConsoleDB();
}
$dbAdapter = $pools
->get($project->getAttribute('database'))
->pop()
->getResource()
;
try {
$dbAdapter = $pools
->get($project->getAttribute('database'))
->pop()
->getResource()
;
} catch (Throwable $error) {
$pools->fill();
$dbAdapter = $pools
->get($project->getAttribute('database'))
->pop()
->getResource()
;
}
$database = new Database($dbAdapter, getCache());
$database->setNamespace('_' . $project->getInternalId());