From cf754d01358448addb7e5d9f847971e03ece37fb Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Wed, 3 Aug 2016 16:07:48 +0200 Subject: [PATCH] Check if serial is an integer, so we know if it's a new zone. Also, return the new zone upon saving it. --- includes/class/PdnsApi.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/class/PdnsApi.php b/includes/class/PdnsApi.php index 5fe11a0..8b12304 100644 --- a/includes/class/PdnsApi.php +++ b/includes/class/PdnsApi.php @@ -52,7 +52,7 @@ class PdnsAPI { unset($zonedata['url']); unset($zonedata['rrsets']); - if ($zone['serial'] == '') { + if (gettype($zone['serial']) != 'integer') { $api->method = 'POST'; $api->url = '/servers/localhost/zones'; $api->content = json_encode($zonedata); @@ -66,9 +66,13 @@ class PdnsAPI { $api->call(); // Then, update the rrsets - $api->method = 'PATCH'; - $api->content = json_encode(Array('rrsets' => $zone['rrsets'])); - $api->call(); + if (count($zone['rrsets']) > 0) { + $api->method = 'PATCH'; + $api->content = json_encode(Array('rrsets' => $zone['rrsets'])); + $api->call(); + } + + return $this->loadzone($zone['id']); } public function deletezone($zoneid) {