From f7b7fa2ac85be4fea7500593e52d5dfa75f29f69 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Thu, 9 Feb 2023 08:40:26 -0800 Subject: [PATCH] map: fix cluster on deletion --- lib/Db/TimelineWrite.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Db/TimelineWrite.php b/lib/Db/TimelineWrite.php index d5c511a8..e2c08594 100644 --- a/lib/Db/TimelineWrite.php +++ b/lib/Db/TimelineWrite.php @@ -233,6 +233,15 @@ class TimelineWrite */ public function deleteFile(File &$file) { + // Get full record + $query = $this->connection->getQueryBuilder(); + $query->select('*') + ->from('memories') + ->where($query->expr()->eq('fileid', $query->createNamedParameter($file->getId(), IQueryBuilder::PARAM_INT))) + ; + $record = $query->executeQuery()->fetch(); + + // Delete all records regardless of existence foreach (DELETE_TABLES as $table) { $query = $this->connection->getQueryBuilder(); $query->delete($table) @@ -240,6 +249,11 @@ class TimelineWrite ; $query->executeStatement(); } + + // Delete from map cluster + if ($record && ($cid = (int) $record['mapcluster']) > 0) { + $this->removeFromCluster($cid, (float) $record['lat'], (float) $record['lon']); + } } /**