Private GIT

Skip to content
Snippets Groups Projects
Unverified Commit cdc62376 authored by Miha Petkovsek's avatar Miha Petkovsek Committed by GitHub
Browse files

Merge pull request #3862 from partoche/fix-issue-2402

Bugfix - update soa serials of affected domains when deleting records
parents 1595aa2b 94415361
Branches
Tags
No related merge requests found
......@@ -686,6 +686,27 @@ class PowerDNS extends Common_functions {
return !is_null($record) ? $record : false;
}
/**
* Searches domains referencing a hostname or ip
*
* @access public
* @param mixed $hostname
* @param mixed $ip
* @return array|boolean
*/
public function search_domains_by_hostname_or_ip ($hostname, $ip) {
// query
$query = "select DISTINCT(`domain_id`) from `records` where `name` = ? or `content` = ? and `type` != 'NS' and `type` != 'SOA';";
// fetch
try { $records = $this->Database_pdns->getObjectsQuery($query, array($hostname, $ip)); }
catch (Exception $e) {
$this->Result->show("danger", _("Error: ").$e->getMessage());
return false;
}
# result
return sizeof($records)>0 ? $records : false;
}
/**
* Searches records for specific domainid for type and name values
*
......@@ -933,6 +954,9 @@ class PowerDNS extends Common_functions {
* @return void
*/
public function pdns_remove_ip_and_hostname_records ($hostname, $ip) {
// find out which domains are going to need an soa serial update
$domains_records = $this->search_domains_by_hostname_or_ip($hostname, $ip);
// set query
$query = "delete from `records` where (`name` = ? or `content` = ?) and `type` != 'NS' and `type` != 'SOA';";
......@@ -942,6 +966,14 @@ class PowerDNS extends Common_functions {
$this->Result->show("danger", _("Error: ").$e->getMessage());
return false;
}
// update soa serial for impacted domains
if($domains_records !== false) {
foreach ($domains_records as $d) {
$this->update_soa_serial ($d->domain_id);
}
}
#result
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment