From 573fd69c958793e3ab0f4d2c61f8aa95ad22f6a3 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Sun, 28 Feb 2016 22:04:57 +0100 Subject: [PATCH] avoid unknown variable if there are no domains in domain-list Signed-off-by: Michael Kaufmann (d00p) --- scripts/jobs/cron_tasks.inc.dns.10.bind.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/jobs/cron_tasks.inc.dns.10.bind.php b/scripts/jobs/cron_tasks.inc.dns.10.bind.php index 1c9abecd..34515c97 100644 --- a/scripts/jobs/cron_tasks.inc.dns.10.bind.php +++ b/scripts/jobs/cron_tasks.inc.dns.10.bind.php @@ -85,6 +85,8 @@ class bind { WHERE `d`.`isbinddomain` = '1' ORDER BY `d`.`domain` ASC "); + $domains = array(); + // don't use fetchall() to be able to set the first column to the domain id and use it later on to set the rows' // array of direct children without having to search the outer array while ($domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { @@ -109,6 +111,11 @@ class bind { $domains['none'] = $hostname_arr; } + if (empty($domains)) { + $this->logger->logAction(CRON_ACTION, LOG_INFO, 'No domains found for nameserver-config, skipping...'); + return; + } + // collect domain IDs of direct child domains as arrays in ['children'] column foreach (array_keys($domains) as $key) { if (!isset($domains[$key]['children'])) {