From 5d2ef8161008e5770e1455277786c7716a553bf3 Mon Sep 17 00:00:00 2001 From: Lukas Metzger Date: Thu, 12 Apr 2018 09:22:32 +0200 Subject: [PATCH] Fixed bug where serial was never incremented --- backend/src/operations/Records.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/backend/src/operations/Records.php b/backend/src/operations/Records.php index d916134..c288e3e 100644 --- a/backend/src/operations/Records.php +++ b/backend/src/operations/Records.php @@ -188,6 +188,9 @@ class Records $record['ttl'] = intval($record['ttl']); $record['domain'] = intval($record['domain']); + $soa = new \Operations\Soa($this->c); + $soa->updateSerial($domain); + $this->db->commit(); return $record; @@ -206,15 +209,19 @@ class Records { $this->db->beginTransaction(); - $query = $this->db->prepare('SELECT id FROM records WHERE id=:id'); + $query = $this->db->prepare('SELECT id,domain_id FROM records WHERE id=:id'); $query->bindValue(':id', $id, \PDO::PARAM_INT); $query->execute(); - if ($query->fetch() === false) { //Domain does not exist + $record = $query->fetch(); + + if ($record === false) { //Domain does not exist $this->db->rollBack(); throw new \Exceptions\NotFoundException(); } + $domainId = intval($record['domain_id']); + $query = $this->db->prepare('DELETE FROM remote WHERE record=:id'); $query->bindValue(':id', $id, \PDO::PARAM_INT); $query->execute(); @@ -223,6 +230,9 @@ class Records $query->bindValue(':id', $id, \PDO::PARAM_INT); $query->execute(); + $soa = new \Operations\Soa($this->c); + $soa->updateSerial($domainId); + $this->db->commit(); } @@ -276,7 +286,7 @@ class Records { $this->db->beginTransaction(); - $query = $this->db->prepare('SELECT id,name,type,content,prio,ttl FROM records WHERE id=:recordId'); + $query = $this->db->prepare('SELECT id,domain_id,name,type,content,prio,ttl FROM records WHERE id=:recordId'); $query->bindValue(':recordId', $recordId); $query->execute(); @@ -291,6 +301,8 @@ class Records throw new \Exceptions\SemanticException(); } + $domainId = intval($record['domain_id']); + $name = $name === null ? $record['name'] : $name; $type = $type === null ? $record['type'] : $type; $content = $content === null ? $record['content'] : $content; @@ -306,6 +318,9 @@ class Records $query->bindValue(':ttl', $ttl); $query->execute(); + $soa = new \Operations\Soa($this->c); + $soa->updateSerial($domainId); + $this->db->commit(); } }