Source
$db_httptests[$row['httptestid']]['steps'][$row['httpstepid']]['items'][$row['itemid']]['tags'][$row['itemtagid']] =
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* Class to perform low level http tests related actions.
*/
class CHttpTestManager {
const ITEM_HISTORY = '30d';
const ITEM_TRENDS = '90d';
/**
* Changed steps names.
* array(
* testid1 => array(nameold1 => namenew1, nameold2 => namenew2),
* ...
* )
*
* @var array
*/
protected $changedSteps = [];
/**
* Map of parent http test id to child http test id.
*
* @var array
*/
protected $httpTestParents = [];
/**
* Array of parent item IDs indexed by parent httptest ID and item key.
*
* @var array
*/
private static $parent_itemids = [];
/**
* Save http test to db.
*
* @param array $httpTests
*
* @return array
*/
public function persist(array $httpTests) {
$this->changedSteps = $this->findChangedStepNames($httpTests);
$httpTests = $this->save($httpTests);
$this->inherit($httpTests);
return $httpTests;
}
/**
* Find steps where name was changed.
*
* @return array
*/
protected function findChangedStepNames(array $httpTests) {
$httpSteps = [];
$result = [];
foreach ($httpTests as $httpTest) {
if (isset($httpTest['httptestid']) && isset($httpTest['steps'])) {
foreach ($httpTest['steps'] as $step) {
if (isset($step['httpstepid']) && isset($step['name'])) {
$httpSteps[$step['httpstepid']] = $step['name'];
}
}
}
}
if (!empty($httpSteps)) {
$dbCursor = DBselect(
'SELECT hs.httpstepid,hs.httptestid,hs.name'.
' FROM httpstep hs'.
' WHERE '.dbConditionInt('hs.httpstepid', array_keys($httpSteps))
);
while ($dbStep = DBfetch($dbCursor)) {
if ($httpSteps[$dbStep['httpstepid']] != $dbStep['name']) {