From ba3750a43cddc8631cc187ee0141f5164e92f124 Mon Sep 17 00:00:00 2001 From: Spanagiot Date: Sun, 19 Jan 2020 20:12:44 +0200 Subject: [PATCH] Change updateRecord behavior Make updateRecord check if any parameters of the record changed if none changed nothing is pushed to the database and serial is not increased This was implemented in order to avoid unecessary changes in serial and zone transfers --- backend/src/operations/Records.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/backend/src/operations/Records.php b/backend/src/operations/Records.php index 77a3f85..11b4ef2 100644 --- a/backend/src/operations/Records.php +++ b/backend/src/operations/Records.php @@ -310,19 +310,20 @@ class Records $content = $content === null ? $record['content'] : $content; $priority = $priority === null ? intval($record['prio']) : $priority; $ttl = $ttl === null ? intval($record['ttl']) : $ttl; + if ($record['name'] != $name || $record['type'] != $type || $record['content'] != $content || intval($record['prio']) != $priority || intval($record['ttl']) != $ttl) { + $query = $this->db->prepare('UPDATE records SET name=:name,type=:type,content=:content,prio=:priority,ttl=:ttl WHERE id=:recordId'); + $query->bindValue('recordId', $recordId); + $query->bindValue(':name', $name); + $query->bindValue(':type', $type); + $query->bindValue(':content', $content); + $query->bindValue(':priority', $priority); + $query->bindValue(':ttl', $ttl); + $query->execute(); - $query = $this->db->prepare('UPDATE records SET name=:name,type=:type,content=:content,prio=:priority,ttl=:ttl WHERE id=:recordId'); - $query->bindValue('recordId', $recordId); - $query->bindValue(':name', $name); - $query->bindValue(':type', $type); - $query->bindValue(':content', $content); - $query->bindValue(':priority', $priority); - $query->bindValue(':ttl', $ttl); - $query->execute(); + $soa = new \Operations\Soa($this->c); + $soa->updateSerial($domainId); - $soa = new \Operations\Soa($this->c); - $soa->updateSerial($domainId); - - $this->db->commit(); + $this->db->commit(); + } } }