From 62b2b400e2c370f3616553ae9a3301c32e0a9179 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Wed, 19 Jun 2013 23:04:55 +0200 Subject: [PATCH] Default to 101 as highest CTID when no containers exist yet. --- frontend/includes/include.misc.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/frontend/includes/include.misc.php b/frontend/includes/include.misc.php index 525fdf7..c050620 100644 --- a/frontend/includes/include.misc.php +++ b/frontend/includes/include.misc.php @@ -61,19 +61,20 @@ function first_unused_ctid() $highest = 101; /* Collect all known CTIDs and keep track of the highest CTID. */ - $result = $database->CachedQuery("SELECT `InternalId` FROM containers WHERE `VirtualizationType` = 1", array(), 0); - - foreach($result->data as $row) + if($result = $database->CachedQuery("SELECT `InternalId` FROM containers WHERE `VirtualizationType` = 1", array(), 0)) { - $id = filter_var($row['InternalId'] ,FILTER_VALIDATE_INT); - - if($id !== false) + foreach($result->data as $row) { - $id_list[] = $id; + $id = filter_var($row['InternalId'] ,FILTER_VALIDATE_INT); - if($id > $highest) + if($id !== false) { - $highest = $id; + $id_list[] = $id; + + if($id > $highest) + { + $highest = $id; + } } } }