fix: avoid n+1 queries

Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
This commit is contained in:
Cleopatra Enjeck M
2024-08-22 10:06:37 +01:00
committed by Cleopatra
parent 5861220b48
commit 86be589717
3 changed files with 10 additions and 12 deletions

View File

@ -264,11 +264,10 @@ class ContextService {
public function deleteNodeRel(int $nodeId, int $nodeType): void {
try {
$nodeRelIds = $this->contextNodeRelMapper->getRelIdsForNode($nodeId, $nodeType);
foreach ($nodeRelIds as $nodeRelId) {
$this->pageContentMapper->deleteByNodeRelId($nodeRelId);
$this->contextNodeRelMapper->deleteByNodeRelId($nodeRelId);
}
$this->atomic(function () use ($nodeRelIds) {
$this->pageContentMapper->deleteByNodeRelIds($nodeRelIds);
$this->contextNodeRelMapper->deleteByNodeRelIds($nodeRelIds);
}, $this->dbc);
} catch (Exception $e) {
$this->logger->error('Something went wrong while deleting node relation for node id: ' . (string)$nodeId . ' and node type ' . (string)$nodeType, ['exception' => $e]);
}