Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix(php): fix problems related to PHP 8.0 upgrade #10297

Merged
merged 6 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 34 additions & 33 deletions www/include/configuration/configObject/host/DB-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,10 @@ function updateHostInDB($host_id = null, $from_MC = false, $cfg = null)
updateHostNotifs($host_id);
}

# Function for updating notification interval options
# 1 - MC with deletion of existing options (Replacement)
# 2 - MC with addition of new options (incremental)
# 3 - Normal update
# Function for updating notification interval options
# 1 - MC with deletion of existing options (Replacement)
# 2 - MC with addition of new options (incremental)
# 3 - Normal update
if (
isset($ret["mc_mod_notifopt_notification_interval"]["mc_mod_notifopt_notification_interval"])
&& $ret["mc_mod_notifopt_notification_interval"]["mc_mod_notifopt_notification_interval"]
Expand All @@ -719,10 +719,10 @@ function updateHostInDB($host_id = null, $from_MC = false, $cfg = null)
updateHostNotifOptionInterval($host_id);
}

# Function for updating first notification delay options
# 1 - MC with deletion of existing options (Replacement)
# 2 - MC with addition of new options (incremental)
# 3 - Normal update, default behavior
# Function for updating first notification delay options
# 1 - MC with deletion of existing options (Replacement)
# 2 - MC with addition of new options (incremental)
# 3 - Normal update, default behavior
if (
isset($ret["mc_mod_notifopt_first_notification_delay"]["mc_mod_notifopt_first_notification_delay"])
&& $ret["mc_mod_notifopt_first_notification_delay"]["mc_mod_notifopt_first_notification_delay"]
Expand All @@ -738,15 +738,15 @@ function updateHostInDB($host_id = null, $from_MC = false, $cfg = null)
}


# Function for updating first notification delay options
# Function for updating first notification delay options
updateHostNotifOptionRecoveryNotificationDelay($host_id);



# Function for updating notification timeperiod options
# 1 - MC with deletion of existing options (Replacement)
# 2 - MC with addition of new options (incremental)
# 3 - Normal update
# Function for updating notification timeperiod options
# 1 - MC with deletion of existing options (Replacement)
# 2 - MC with addition of new options (incremental)
# 3 - Normal update
if (
isset($ret["mc_mod_notifopt_timeperiod"]["mc_mod_notifopt_timeperiod"])
&& $ret["mc_mod_notifopt_timeperiod"]["mc_mod_notifopt_timeperiod"]
Expand All @@ -761,10 +761,10 @@ function updateHostInDB($host_id = null, $from_MC = false, $cfg = null)
updateHostNotifOptionTimeperiod($host_id);
}

# Function for updating host hg
# 1 - MC with deletion of existing hg
# 2 - MC with addition of new hg
# 3 - Normal update
# Function for updating host hg
# 1 - MC with deletion of existing hg
# 2 - MC with addition of new hg
# 3 - Normal update
if (isset($ret["mc_mod_hhg"]["mc_mod_hhg"]) && $ret["mc_mod_hhg"]["mc_mod_hhg"]) {
updateHostHostGroup($host_id);
} elseif (isset($ret["mc_mod_hhg"]["mc_mod_hhg"]) && !$ret["mc_mod_hhg"]["mc_mod_hhg"]) {
Expand All @@ -773,10 +773,10 @@ function updateHostInDB($host_id = null, $from_MC = false, $cfg = null)
updateHostHostGroup($host_id);
}

# Function for updating host hc
# 1 - MC with deletion of existing hc
# 2 - MC with addition of new hc
# 3 - Normal update
# Function for updating host hc
# 1 - MC with deletion of existing hc
# 2 - MC with addition of new hc
# 3 - Normal update
if (isset($ret["mc_mod_hhc"]["mc_mod_hhc"]) && $ret["mc_mod_hhc"]["mc_mod_hhc"]) {
updateHostHostCategory($host_id);
} elseif (isset($ret["mc_mod_hhc"]["mc_mod_hhc"]) && !$ret["mc_mod_hhc"]["mc_mod_hhc"]) {
Expand All @@ -785,10 +785,10 @@ function updateHostInDB($host_id = null, $from_MC = false, $cfg = null)
updateHostHostCategory($host_id, $ret);
}

# Function for updating host template
# 1 - MC with deletion of existing template
# 2 - MC with addition of new template
# 3 - Normal update
# Function for updating host template
# 1 - MC with deletion of existing template
# 2 - MC with addition of new template
# 3 - Normal update
if (isset($ret["mc_mod_htpl"]["mc_mod_htpl"]) && $ret["mc_mod_htpl"]["mc_mod_htpl"]) {
updateHostTemplateService($host_id);
} elseif (isset($ret["mc_mod_htpl"]["mc_mod_htpl"]) && !$ret["mc_mod_htpl"]["mc_mod_htpl"]) {
Expand Down Expand Up @@ -2316,7 +2316,6 @@ function updateHostTemplateService_MC($host_id = null)
if (!$host_id) {
return;
}

$dbResult = $pearDB->query("SELECT host_register FROM host WHERE host_id = '" . (int)$host_id . "'");
$row = $dbResult->fetch();
if ($row["host_register"] == 0) {
Expand All @@ -2329,13 +2328,15 @@ function updateHostTemplateService_MC($host_id = null)
}

$ret = $form->getSubmitValue("host_svTpls");
for ($i = 0; $i < count($ret); $i++) {
if (!isset($svtpls[$ret[$i]])) {
$rq = "INSERT INTO host_service_relation ";
$rq .= "(hostgroup_hg_id, host_host_id, servicegroup_sg_id, service_service_id) ";
$rq .= "VALUES ";
$rq .= "(NULL, '" . (int)$host_id . "', NULL, '" . $ret[$i] . "')";
$dbResult2 = $pearDB->query($rq);
if (!empty($ret)) {
for ($i = 0; $i < count($ret); $i++) {
if (!isset($svtpls[$ret[$i]])) {
$rq = "INSERT INTO host_service_relation ";
$rq .= "(hostgroup_hg_id, host_host_id, servicegroup_sg_id, service_service_id) ";
$rq .= "VALUES ";
$rq .= "(NULL, '" . (int)$host_id . "', NULL, '" . $ret[$i] . "')";
$dbResult2 = $pearDB->query($rq);
}
}
}
} elseif ($centreon->user->get_version() >= 3) {
Expand Down
6 changes: 4 additions & 2 deletions www/include/configuration/configObject/service/DB-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ function divideHostGroupsToHostGroup($service_id)

$query = "SELECT hostgroup_hg_id FROM host_service_relation " .
"WHERE service_service_id = '" . $service_id . "' AND hostgroup_hg_id IS NOT NULL";
$dbResult3 = $pearDB->query();
while ($data = $dbResult3->fetch($query)) {
$dbResult3 = $pearDB->query($query);
while ($data = $dbResult3->fetch()) {
$sv_id = multipleServiceInDB(
array($service_id => "1"),
array($service_id => "1"),
Expand Down Expand Up @@ -1753,6 +1753,8 @@ function updateServiceNotifs($service_id = null, $ret = array())
// For massive change. incremental mode
function updateServiceNotifs_MC($service_id = null)
{
require_once "./include/common/javascript/commandGetArgs/cmdGetExample.php";
AssanDiomande marked this conversation as resolved.
Show resolved Hide resolved

if (!$service_id) {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions www/include/options/media/images/formDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@
##########################################################
# Var information to format the element
#
$attrsText = array("size"=>"30");
$attrsSelect = array("size"=>"5", "multiple"=>"1", "cols"=>"40");
$attrsText = array("size" => "30");
$attrsSelect = array("size" => "5", "multiple" => "1", "cols" => "40", "required" => "true");
$attrsAdvSelect = array("style" => "width: 250px; height: 250px;");
$attrsTextarea = array("rows"=>"5", "cols"=>"40");
$attrsTextarea = array("rows" => "5", "cols" => "40");

#
## Form begin
Expand Down
11 changes: 5 additions & 6 deletions www/include/options/media/images/images.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@
FILTER_VALIDATE_INT
);

// If one data are not correctly typed in array, it will be set to false
$selectIds = filter_var_array(
$_GET["select"] ?? $_POST["select"] ?? array(),
FILTER_VALIDATE_INT
);

/*
* Path to the cities dir
*/
Expand Down Expand Up @@ -95,6 +89,11 @@
require_once($path . "formDirectory.php");
break;
case IMAGE_DELETE:
// If one data are not correctly typed in array, it will be set to false
$selectIds = filter_var_array(
kduret marked this conversation as resolved.
Show resolved Hide resolved
$_GET["select"] ?? $_POST["select"] ?? array(),
FILTER_VALIDATE_INT
);
purgeOutdatedCSRFTokens();
if (isCSRFTokenValid()) {
purgeCSRFToken();
Expand Down