From fe0de6e9cb1bfd187b961fa352247aeb3eeaa6d6 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 24 Feb 2023 01:38:31 -0800 Subject: [PATCH] tw: wrap map ops in transaction --- lib/Db/TimelineWriteMap.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Db/TimelineWriteMap.php b/lib/Db/TimelineWriteMap.php index 657d0aef..4233fd46 100644 --- a/lib/Db/TimelineWriteMap.php +++ b/lib/Db/TimelineWriteMap.php @@ -82,6 +82,8 @@ trait TimelineWriteMap return; } + $this->connection->beginTransaction(); + $query = $this->connection->getQueryBuilder(); $query->update('memories_mapclusters') ->set('point_count', $query->createFunction('point_count + 1')) @@ -92,6 +94,8 @@ trait TimelineWriteMap $query->executeStatement(); $this->mapUpdateAggregates($clusterId); + + $this->connection->commit(); } /** @@ -104,6 +108,8 @@ trait TimelineWriteMap */ private function mapCreateCluster(float $lat, float $lon): int { + $this->connection->beginTransaction(); + $query = $this->connection->getQueryBuilder(); $query->insert('memories_mapclusters') ->values([ @@ -117,6 +123,8 @@ trait TimelineWriteMap $clusterId = (int) $query->getLastInsertId(); $this->mapUpdateAggregates($clusterId); + $this->connection->commit(); + return $clusterId; } @@ -133,6 +141,8 @@ trait TimelineWriteMap return; } + $this->connection->beginTransaction(); + $query = $this->connection->getQueryBuilder(); $query->update('memories_mapclusters') ->set('point_count', $query->createFunction('point_count - 1')) @@ -143,6 +153,8 @@ trait TimelineWriteMap $query->executeStatement(); $this->mapUpdateAggregates($clusterId); + + $this->connection->commit(); } /**