diff options
Diffstat (limited to 'ui/include/classes/api/services/CTemplate.php')
-rw-r--r-- | ui/include/classes/api/services/CTemplate.php | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/ui/include/classes/api/services/CTemplate.php b/ui/include/classes/api/services/CTemplate.php index 2d10d49ccd8..0c392c7f3a7 100644 --- a/ui/include/classes/api/services/CTemplate.php +++ b/ui/include/classes/api/services/CTemplate.php @@ -532,19 +532,24 @@ class CTemplate extends CHostGeneral { 'nopermissions' => true, 'preservekeys' => true ]); + if ($del_rules) { CDiscoveryRuleManager::delete(array_keys($del_rules)); } // delete the items - $del_items = API::Item()->get([ - 'output' => [], - 'templateids' => $templateids, - 'nopermissions' => true, + $db_items = DB::select('items', [ + 'output' => ['itemid', 'name'], + 'filter' => [ + 'hostid' => $templateids, + 'flags' => ZBX_FLAG_DISCOVERY_NORMAL, + 'type' => CItem::SUPPORTED_ITEM_TYPES + ], 'preservekeys' => true ]); - if ($del_items) { - CItemManager::delete(array_keys($del_items)); + + if ($db_items) { + CItem::deleteForce($db_items); } // delete host from maps @@ -616,15 +621,15 @@ class CTemplate extends CHostGeneral { 'operationid'=>$delOperationids ]); - // http tests - $delHttpTests = API::HttpTest()->get([ - 'templateids' => $templateids, - 'output' => ['httptestid'], - 'nopermissions' => 1, + // delete web scenarios + $db_httptests = DB::select('httptest', [ + 'output' => ['httptestid', 'name'], + 'filter' => ['hostid' => $templateids], 'preservekeys' => true ]); - if (!empty($delHttpTests)) { - API::HttpTest()->delete(array_keys($delHttpTests), true); + + if ($db_httptests) { + CHttpTest::deleteForce($db_httptests); } // Get host prototype operations from LLD overrides where this template is linked. |