diff --git a/lib/Db/ExAppMapper.php b/lib/Db/ExAppMapper.php index 45322fa0..300deb1c 100644 --- a/lib/Db/ExAppMapper.php +++ b/lib/Db/ExAppMapper.php @@ -78,10 +78,10 @@ public function findByAppId(string $appId): Entity { ); $apps = $this->buildExAppRoutes($qb->executeQuery()->fetchAll()); if (count($apps) === 0) { - throw new DoesNotExistException(); + throw new DoesNotExistException('No ExApp found with appId ' . $appId); } if (count($apps) > 1) { - throw new MultipleObjectsReturnedException(); + throw new MultipleObjectsReturnedException('Multiple ExApps found with appId ' . $appId); } return $apps[0]; } @@ -208,24 +208,6 @@ public function registerExAppRoutes(ExApp $exApp, array $routes): int { return $count; } - /** - * @throws Exception - */ - public function updateExAppRoutes(ExApp $exApp, array $routes): int { - $count = 0; - foreach ($routes as $route) { - $qb = $this->db->getQueryBuilder(); - $qb->update('ex_apps_routes') - ->set('url', $qb->createNamedParameter($route['url'])) - ->set('verb', $qb->createNamedParameter($route['verb'])) - ->set('access_level', $qb->createNamedParameter($route['access_level'])) - ->set('headers_to_exclude', $qb->createNamedParameter($route['headers_to_exclude'])) - ->where($qb->expr()->eq('appid', $qb->createNamedParameter($exApp->getAppid()))); - $count += $qb->executeStatement(); - } - return $count; - } - /** * @throws Exception */ diff --git a/lib/Service/ExAppService.php b/lib/Service/ExAppService.php index 323d850e..4e9522c1 100644 --- a/lib/Service/ExAppService.php +++ b/lib/Service/ExAppService.php @@ -117,12 +117,12 @@ public function unregisterExApp(string $appId): bool { if ($r !== 1) { $this->logger->error(sprintf('Error while unregistering %s ExApp from the database.', $appId)); } - $r = $this->removeExAppRoutes($exApp); - if ($r === null) { + $rmRoutes = $this->removeExAppRoutes($exApp); + if ($rmRoutes === null) { $this->logger->error(sprintf('Error while unregistering %s ExApp routes from the database.', $appId)); } $this->cache->remove('/ex_apps'); - return $r === 1; + return $r === 1 && $rmRoutes !== null; } public function getExAppFreePort(): int { @@ -383,17 +383,4 @@ public function removeExAppRoutes(ExApp $exApp): ?ExApp { return null; } } - - public function updateExAppRoutes(ExApp $exApp, array $routes): ?ExApp { - try { - if ($this->exAppMapper->updateExAppRoutes($exApp, $routes) === count($routes)) { - $exApp->setRoutes($routes); - $this->resetCaches(); - return $exApp; - } - } catch (Exception) { - return null; - } - return null; - } } diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index 12105348..18bc02ac 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -11,6 +11,8 @@ + + @@ -18,6 +20,12 @@ + + + + + +