diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 988f061ed5..765688e1ee 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -538,7 +538,7 @@ App::get('/v1/health/queue/databases') ->inject('response') ->action(function (string $name, int|string $threshold, Database $queueForDatabase, Response $response) { $threshold = \intval($threshold); - $size = $queueForDatabase->getSize(); + $size = $queueForDatabase->setQueue($name)->getSize(); if ($size >= $threshold) { throw new Exception(Exception::HEALTH_QUEUE_SIZE_EXCEEDED, "Queue size threshold hit. Current size is {$size} and threshold is {$threshold}."); diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index 70051f9055..8e7f6b7625 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -161,17 +161,20 @@ class Database extends Event return $this->document; } - public function getQueue(): string + public function setProject(Document $project): self { - try { - $dsn = new DSN($this->getProject()->getAttribute('database')); - } catch (\InvalidArgumentException) { - // TODO: Temporary until all projects are using shared tables - $dsn = new DSN('mysql://' . $this->getProject()->getAttribute('database')); + $database = $project->getAttribute('database'); + if (!empty($database)) { + try { + $dsn = new DSN($database); + } catch (\InvalidArgumentException) { + // TODO: Temporary until all projects are using shared tables + $dsn = new DSN("mysql://$database"); + } + $this->queue = $dsn->getHost(); } - $this->queue = $dsn->getHost(); - return $this->queue; + return parent::setProject($project); } /**