From 7473fbe0e4315d5d1ee1a0c845c67a0f6163e885 Mon Sep 17 00:00:00 2001 From: Toufik MECHOUET Date: Mon, 26 Oct 2015 13:56:57 +0100 Subject: [PATCH] Fix issue #3824 PHP Warning: array_map(): Argument #2 should be an array --- www/class/centreonHost.class.php | 8 +++++--- .../host_template_model/formHostTemplateModel.php | 2 +- .../configuration/configObject/service/formService.php | 2 +- .../service_template_model/formServiceTemplateModel.php | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/www/class/centreonHost.class.php b/www/class/centreonHost.class.php index 1bf737033aa..fe544bc1197 100644 --- a/www/class/centreonHost.class.php +++ b/www/class/centreonHost.class.php @@ -559,9 +559,11 @@ public function getTemplates($hostId = null) { $i++; } } else { - foreach ($_REQUEST['tpSelect'] as $val) { - $arr[$i]['tpSelect_#index#'] = $val; - $i++; + if (isset($_REQUEST['tpSelect'])) { + foreach ($_REQUEST['tpSelect'] as $val) { + $arr[$i]['tpSelect_#index#'] = $val; + $i++; + } } } return $arr; diff --git a/www/include/configuration/configObject/host_template_model/formHostTemplateModel.php b/www/include/configuration/configObject/host_template_model/formHostTemplateModel.php index 58c70143524..ae2eeacad36 100644 --- a/www/include/configuration/configObject/host_template_model/formHostTemplateModel.php +++ b/www/include/configuration/configObject/host_template_model/formHostTemplateModel.php @@ -46,7 +46,7 @@ # $host = array(); if (($o == "c" || $o == "w") && $host_id) { - $DBRESULT = $pearDB->query("SELECT * FROM host, extended_host_information ehi WHERE host_id = '".$host_id."' AND ehi.host_host_id = host.host_id LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM host LEFT JOIN extended_host_information ehi ON ehi.host_host_id = host.host_id WHERE host_id = '".$host_id."' LIMIT 1"); # Set base value if ($DBRESULT->numRows()) { diff --git a/www/include/configuration/configObject/service/formService.php b/www/include/configuration/configObject/service/formService.php index 90e74e72c8d..981edfc106d 100644 --- a/www/include/configuration/configObject/service/formService.php +++ b/www/include/configuration/configObject/service/formService.php @@ -135,7 +135,7 @@ function myDecodeService($arg) { $initialValues = array(); if (($o == "c" || $o == "w") && $service_id) { - $DBRESULT = $pearDB->query("SELECT * FROM service, extended_service_information esi WHERE service_id = '".$service_id."' AND esi.service_service_id = service_id LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM service LEFT JOIN extended_service_information esi ON esi.service_service_id = service_id WHERE service_id = '".$service_id."' LIMIT 1"); /* * Set base value */ diff --git a/www/include/configuration/configObject/service_template_model/formServiceTemplateModel.php b/www/include/configuration/configObject/service_template_model/formServiceTemplateModel.php index b570e992def..5c7c95bc5fd 100644 --- a/www/include/configuration/configObject/service_template_model/formServiceTemplateModel.php +++ b/www/include/configuration/configObject/service_template_model/formServiceTemplateModel.php @@ -57,7 +57,7 @@ function myDecodeSvTP($arg) { if (isset($lockedElements[$service_id])) { $o = "w"; } - $DBRESULT = $pearDB->query("SELECT * FROM service, extended_service_information esi WHERE service_id = '".$service_id."' AND esi.service_service_id = service_id LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM service LEFT JOIN extended_service_information esi ON esi.service_service_id = service_id WHERE service_id = '".$service_id."' LIMIT 1"); // Set base value $service_list = $DBRESULT->fetchRow(); $service = array_map("myDecodeSvTP", $service_list);