Skip to content

Commit 0614b51

Browse files
author
Carsten Schoene
committed
fix duplicate entry caused in rr_insert
1 parent bbc4ad9 commit 0614b51

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

server/plugins-available/powerdns_plugin.inc.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function soa_update($event_name, $data) {
165165
$this->soa_delete($event_name, $data);
166166
} else {
167167
$exists = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ".$data["new"]["id"]);
168-
if($data["old"]["active"] == 'Y' && $exists){
168+
if($data["old"]["active"] == 'Y' && is_array($exists)){
169169
$origin = substr($data["new"]["origin"], 0, -1);
170170
$ispconfig_id = $data["new"]["id"];
171171

@@ -273,6 +273,8 @@ function slave_delete($event_name, $data) {
273273
function rr_insert($event_name, $data) {
274274
global $app, $conf;
275275
if($data["new"]["active"] != 'Y') return;
276+
$exists = $app->db->queryOneRecord("SELECT * FROM powerdns.records WHERE ispconfig_id = ".$data["new"]["id"]);
277+
if ( is_array($exists) ) return;
276278

277279
$zone = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$data["new"]["zone"]);
278280
$origin = substr($zone["origin"], 0, -1);
@@ -339,7 +341,7 @@ function rr_update($event_name, $data) {
339341
$this->rr_delete($event_name, $data);
340342
} else {
341343
$exists = $app->db->queryOneRecord("SELECT * FROM powerdns.records WHERE ispconfig_id = ".$data["new"]["id"]);
342-
if($data["old"]["active"] == 'Y' && $exists){
344+
if($data["old"]["active"] == 'Y' && is_array($exists)){
343345
$zone = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$data["new"]["zone"]);
344346
$origin = substr($zone["origin"], 0, -1);
345347
$powerdns_zone = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ".$data["new"]["zone"]." AND type = 'MASTER'");

0 commit comments

Comments
 (0)