From ef4cc82ded1391a816d7510d2a34618a03339380 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 20 Jan 2025 17:56:51 +1300 Subject: [PATCH] Connection in project for DB --- app/init.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/init.php b/app/init.php index 5cd6eba9a8..f8dec38394 100644 --- a/app/init.php +++ b/app/init.php @@ -1501,10 +1501,10 @@ App::setResource('dbForPlatform', function (Group $pools, Cache $cache) { return $database; }, ['pools', 'cache']); -App::setResource('getProjectDB', function (Group $pools, Database $dbForPlatform, $cache) { - $databases = []; // TODO: @Meldiron This should probably be responsibility of utopia-php/pools +App::setResource('getProjectDB', function (Group $pools, PoolConnection $connectionForProject, Database $dbForPlatform, $cache) { + $databases = []; - return function (Document $project) use ($pools, $dbForPlatform, $cache, &$databases) { + return function (Document $project) use ($pools, $connectionForProject, $dbForPlatform, $cache, &$databases) { if ($project->isEmpty() || $project->getId() === 'console') { return $dbForPlatform; } @@ -1544,10 +1544,7 @@ App::setResource('getProjectDB', function (Group $pools, Database $dbForPlatform return $database; } - $dbAdapter = $pools - ->get($dsn->getHost()) - ->pop() - ->getResource(); + $dbAdapter = $connectionForProject->getResource(); $database = new Database($dbAdapter, $cache); $databases[$dsn->getHost()] = $database;