Fixed bug where serial was never incremented

This commit is contained in:
Lukas Metzger 2018-04-12 09:22:32 +02:00
parent a0548c0e01
commit 5d2ef81610

View file

@ -188,6 +188,9 @@ class Records
$record['ttl'] = intval($record['ttl']); $record['ttl'] = intval($record['ttl']);
$record['domain'] = intval($record['domain']); $record['domain'] = intval($record['domain']);
$soa = new \Operations\Soa($this->c);
$soa->updateSerial($domain);
$this->db->commit(); $this->db->commit();
return $record; return $record;
@ -206,15 +209,19 @@ class Records
{ {
$this->db->beginTransaction(); $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->bindValue(':id', $id, \PDO::PARAM_INT);
$query->execute(); $query->execute();
if ($query->fetch() === false) { //Domain does not exist $record = $query->fetch();
if ($record === false) { //Domain does not exist
$this->db->rollBack(); $this->db->rollBack();
throw new \Exceptions\NotFoundException(); throw new \Exceptions\NotFoundException();
} }
$domainId = intval($record['domain_id']);
$query = $this->db->prepare('DELETE FROM remote WHERE record=:id'); $query = $this->db->prepare('DELETE FROM remote WHERE record=:id');
$query->bindValue(':id', $id, \PDO::PARAM_INT); $query->bindValue(':id', $id, \PDO::PARAM_INT);
$query->execute(); $query->execute();
@ -223,6 +230,9 @@ class Records
$query->bindValue(':id', $id, \PDO::PARAM_INT); $query->bindValue(':id', $id, \PDO::PARAM_INT);
$query->execute(); $query->execute();
$soa = new \Operations\Soa($this->c);
$soa->updateSerial($domainId);
$this->db->commit(); $this->db->commit();
} }
@ -276,7 +286,7 @@ class Records
{ {
$this->db->beginTransaction(); $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->bindValue(':recordId', $recordId);
$query->execute(); $query->execute();
@ -291,6 +301,8 @@ class Records
throw new \Exceptions\SemanticException(); throw new \Exceptions\SemanticException();
} }
$domainId = intval($record['domain_id']);
$name = $name === null ? $record['name'] : $name; $name = $name === null ? $record['name'] : $name;
$type = $type === null ? $record['type'] : $type; $type = $type === null ? $record['type'] : $type;
$content = $content === null ? $record['content'] : $content; $content = $content === null ? $record['content'] : $content;
@ -306,6 +318,9 @@ class Records
$query->bindValue(':ttl', $ttl); $query->bindValue(':ttl', $ttl);
$query->execute(); $query->execute();
$soa = new \Operations\Soa($this->c);
$soa->updateSerial($domainId);
$this->db->commit(); $this->db->commit();
} }
} }