From 8d5e92e288a2429bf78ea48d12de81c693bcded4 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Thu, 17 Sep 2026 21:41:29 +0530 Subject: [PATCH] fix(mqtt): resolve getProjectDB via the container in the SUBSCRIBE authorizer The DI refactor moved the broker's DB/cache resolvers onto the container but left the authorizer closure calling the removed global getProjectDB(), so every SUBSCRIBE threw "Call to undefined function getProjectDB()" before the SUBACK (CONNECT was unaffected as it only uses the authenticator). --- app/init/mqtt/connection.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/init/mqtt/connection.php b/app/init/mqtt/connection.php index 50ae943d63..baeef339fa 100644 --- a/app/init/mqtt/connection.php +++ b/app/init/mqtt/connection.php @@ -108,8 +108,8 @@ return function (Container $container): void { }; }, []); - $container->set('authorizer', function () use ($getProject): callable { - return function (array $identity, string $topic) use ($getProject): bool { + $container->set('authorizer', function () use ($getProject, $container): callable { + return function (array $identity, string $topic) use ($getProject, $container): bool { $userId = $identity['userId'] ?? ''; $projectId = $identity['projectId'] ?? ''; if ($userId === '' || $projectId === '') { @@ -123,7 +123,8 @@ return function (Container $container): void { return false; } - $dbForProject = getProjectDB($project); + $getProjectDB = $container->get('getProjectDB'); + $dbForProject = $getProjectDB($project); $dbForProject->setAuthorization($authorization); $user = $authorization->skip(fn () => $dbForProject->getDocument('users', $userId));