Skip to content

Commit eff5230

Browse files
committed
Avoid running checkzone for each rr when inserting/deleting a soa by deactivating the zone first, #6647
1 parent 385e219 commit eff5230

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

interface/lib/classes/dns_wizard.inc.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ function create(array $data)
268268
"expire" => $expire,
269269
"minimum" => $minimum,
270270
"ttl" => $ttl,
271-
"active" => 'Y',
271+
"active" => 'N', // Activated later when all DNS records are added.
272272
"xfer" => $xfer,
273273
"also_notify" => $also_notify,
274274
"update_acl" => $update_acl,
@@ -301,6 +301,9 @@ function create(array $data)
301301
}
302302
}
303303

304+
// Activate the DNS zone.
305+
$app->db->datalogUpdate('dns_soa', array('active' => 'Y'), 'id', $dns_soa_id);
306+
304307
return 'ok';
305308

306309
} else {

interface/web/dns/dns_import.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ function fqdn_name( $owner, $origin ) {
677677
"expire" => $soa['expire'],
678678
"minimum" => $soa['minimum'],
679679
"ttl" => $soa['ttl'],
680-
"active" => 'Y',
680+
"active" => 'N', // Activated later when all DNS records are added.
681681
"xfer" => $xfer
682682
);
683683
$dns_soa_id = $app->db->datalogInsert('dns_soa', $insert_data, 'id');
@@ -710,6 +710,9 @@ function fqdn_name( $owner, $origin ) {
710710
$dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id');
711711
}
712712

713+
// Activate the DNS zone.
714+
$app->db->datalogUpdate('dns_soa', array('active' => 'Y'), 'id', $dns_soa_id);
715+
713716
$msg[] = $wb['zone_file_successfully_imported_txt'];
714717
} elseif (is_array($dns_rr)) {
715718
$error[] = $wb['zone_file_import_fail'];

interface/web/dns/dns_soa_del.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ function onBeforeDelete() {
5555

5656
if($app->tform->checkPerm($this->id, 'd') == false) $app->error($app->lng('error_no_delete_permission'));
5757

58+
$app->db->datalogUpdate('dns_soa', array("active" => 'N'), 'id', $this->id);
59+
5860
// Delete all records that belong to this zone.
5961
$records = $app->db->queryAllRecords("SELECT id FROM dns_rr WHERE zone = ?", $this->id);
6062
foreach($records as $rec) {

server/plugins-available/bind_plugin.inc.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ function soa_update($event_name, $data) {
352352
$loglevel = @($dns_config['disable_bind_log'] === 'y') ? LOGLEVEL_DEBUG : LOGLEVEL_WARN;
353353
$app->log("Writing BIND domain file failed: ".$filename." ".implode(' ', $out), $loglevel);
354354
if(is_array($out) && !empty($out)){
355-
$app->log('Reason for Bind zone check failure: '.implode("\n", $out), $loglevel);
355+
$app->log('Reason for Bind zone check failure: '.implode("\n", $out), $loglevel);
356356
$app->dbmaster->datalogError(implode("\n", $out));
357357
}
358358
if ($old_zonefile != '') {
@@ -505,7 +505,10 @@ function rr_insert($event_name, $data) {
505505
$data["new"] = $tmp;
506506
$data["old"] = $tmp;
507507
$this->action = 'update';
508-
$this->soa_update($event_name, $data);
508+
509+
if (isset($data['new']['active']) && $data['new']['active'] == 'Y') {
510+
$this->soa_update($event_name, $data);
511+
}
509512

510513
}
511514

@@ -525,11 +528,15 @@ function rr_delete($event_name, $data) {
525528
global $app, $conf;
526529

527530
//* Get the data of the soa and call soa_update
531+
//* In a singel server setup the record in dns_soa will already be gone ... so this will give an empty array.
528532
$tmp = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ?", $data['old']['zone']);
529533
$data["new"] = $tmp;
530534
$data["old"] = $tmp;
531535
$this->action = 'update';
532-
$this->soa_update($event_name, $data);
536+
537+
if (isset($data['new']['active']) && $data['new']['active'] == 'Y') {
538+
$this->soa_update($event_name, $data);
539+
}
533540

534541
}
535542

0 commit comments

Comments
 (0)