IcingaServiceSetTable: do not trust a Servicve Set

...name, as the Template might have been renamed in the meantime - and the
name on the Set "object" has no meaning at all

fixes #1664
This commit is contained in:
Thomas Gelf 2018-10-04 18:30:27 +02:00
parent ea18006819
commit 33053103e1

View File

@ -165,14 +165,24 @@ class IcingaServiceSetServiceTable extends ZfQueryBasedTable
'name' => $this->host->getObjectName() 'name' => $this->host->getObjectName()
]) ])
); );
$hostId = $this->host->get('id'); $deleteLink->runOnSuccess(function () {
$setName = $this->set->getObjectName(); $conn = $this->set->getConnection();
$db = $this->set->getConnection(); $db = $conn->getDbAdapter();
$deleteLink->runOnSuccess(function () use ($db, $hostId, $setName) { $query = $db->select()->from(
IcingaServiceSet::load([ ['ss' => 'icinga_service_set'],
'host_id' => $hostId, 'ss.id'
'object_name' => $setName )->join(
], $db)->delete(); ['ssih' => 'icinga_service_set_inheritance'],
'ssih.service_set_id = ss.id',
[]
)->where(
'ssih.parent_service_set_id = ?',
$this->set->get('id')
)->where('ss.host_id = ?', $this->host->get('id'));
IcingaServiceSet::loadWithAutoIncId(
$db->fetchOne($query),
$conn
)->delete();
}); });
$deleteLink->handleRequest(); $deleteLink->handleRequest();
} }