Skip to content

Commit b571cfe

Browse files
committed
Avoid running checkzone for each rr when deleting a soa, #6647
1 parent b97a629 commit b571cfe

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

interface/lib/classes/db_mysql.inc.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ public function getDatabaseSize($database_name) {
686686
}
687687

688688
//** Function to fill the datalog with a full differential record.
689-
public function datalogSave($db_table, $action, $primary_field, $primary_id, $record_old, $record_new, $force_update = false) {
689+
public function datalogSave($db_table, $action, $primary_field, $primary_id, $record_old, $record_new, $force_update = false, $options = []) {
690690
global $app;
691691

692692
// Insert backticks only for incomplete table names.
@@ -712,6 +712,7 @@ public function datalogSave($db_table, $action, $primary_field, $primary_id, $re
712712
$server_id = (isset($record_old['server_id']) && $record_old['server_id'] > 0)?$record_old['server_id']:0;
713713
if(isset($record_new['server_id'])) $server_id = $record_new['server_id'];
714714

715+
$diffrec_full['options'] = $options;
715716

716717
if($diff_num > 0) {
717718
$diffstr = serialize($diffrec_full);
@@ -810,7 +811,7 @@ public function datalogUpdate($tablename, $update_data, $index_field, $index_val
810811
}
811812

812813
//** Deletes a record and saves the changes into the datalog
813-
public function datalogDelete($tablename, $index_field, $index_value) {
814+
public function datalogDelete($tablename, $index_field, $index_value, $options = []) {
814815
global $app;
815816

816817
// Check fields
@@ -820,7 +821,7 @@ public function datalogDelete($tablename, $index_field, $index_value) {
820821
$old_rec = $this->queryOneRecord("SELECT * FROM ?? WHERE ?? = ?", $tablename, $index_field, $index_value);
821822
$this->query("DELETE FROM ?? WHERE ?? = ?", $tablename, $index_field, $index_value);
822823
$new_rec = array();
823-
$this->datalogSave($tablename, 'DELETE', $index_field, $index_value, $old_rec, $new_rec);
824+
$this->datalogSave($tablename, 'DELETE', $index_field, $index_value, $old_rec, $new_rec, FALSE, $options);
824825

825826
return true;
826827
}

interface/web/dns/dns_soa_del.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ function onBeforeDelete() {
5555

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

58-
// Delete all records that belog to this zone.
58+
// Delete all records that belong to this zone.
5959
$records = $app->db->queryAllRecords("SELECT id FROM dns_rr WHERE zone = ?", $this->id);
60+
$options = ['deleting_dns_soa' => TRUE];
6061
foreach($records as $rec) {
61-
$app->db->datalogDelete('dns_rr', 'id', $rec['id']);
62+
$app->db->datalogDelete('dns_rr', 'id', $rec['id'], $options);
6263
}
6364
}
6465

server/plugins-available/bind_plugin.inc.php

Lines changed: 6 additions & 1 deletion
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 restart 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 != '') {
@@ -524,6 +524,11 @@ function rr_update($event_name, $data) {
524524
function rr_delete($event_name, $data) {
525525
global $app, $conf;
526526

527+
if (!empty($data['options']['deleting_dns_soa']) && $data['options']['deleting_dns_soa'] == TRUE) {
528+
$app->log("Skipping zone update since it's alse being deleted", LOGLEVEL_DEBUG);
529+
return;
530+
}
531+
527532
//* Get the data of the soa and call soa_update
528533
$tmp = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ?", $data['old']['zone']);
529534
$data["new"] = $tmp;

0 commit comments

Comments
 (0)