From 2f9c7171eab8ac030a6c210ca3873a164afab91a Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 29 Apr 2016 16:04:10 -0600 Subject: [PATCH] Check additional arrays to see if they are exist before using them in a foreach. --- core/domain_settings/domain_delete.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/domain_settings/domain_delete.php b/core/domain_settings/domain_delete.php index 7e544a963a..282051da37 100644 --- a/core/domain_settings/domain_delete.php +++ b/core/domain_settings/domain_delete.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2016 the Initial Developer. All Rights Reserved. Contributor(s): @@ -50,7 +50,7 @@ if (strlen($id) > 0) { $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($result as &$row) { + if (isset($result)) foreach ($result as &$row) { $domain_name = $row["domain_name"]; } unset ($prep_statement); @@ -62,7 +62,7 @@ if (strlen($id) > 0) { $prep_statement = $db->prepare($sql); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach($result as $row) { + if (isset($result)) foreach($result as $row) { $name = $row['domain_setting_name']; $category = $row['domain_setting_category']; $subcategory = $row['domain_setting_subcategory']; @@ -87,17 +87,17 @@ if (strlen($id) > 0) { //get the $apps array from the installed apps from the core and mod directories $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); $x=0; - foreach ($config_list as &$config_path) { + if (isset($config_list)) foreach ($config_list as &$config_path) { include($config_path); $x++; } //delete the domain data from all tables in the database $db->beginTransaction(); - foreach ($apps as &$app) { - foreach ($app['db'] as $row) { + if (isset($apps)) foreach ($apps as &$app) { + if (isset($app['db'])) foreach ($app['db'] as $row) { $table_name = $row['table']; - foreach ($row['fields'] as $field) { + if (isset(foreach ($row['fields'])) foreach ($row['fields'] as $field) { if ($field['name'] == "domain_uuid") { $sql = "delete from $table_name where domain_uuid = '$id' "; $db->query($sql);