IcingaService: single objects w/o host must fail

fixes #1236
This commit is contained in:
Thomas Gelf 2017-10-12 17:01:20 +02:00
parent 0e10545175
commit 6490283647
2 changed files with 19 additions and 0 deletions

View File

@ -18,6 +18,11 @@ before switching to a new version.
* FEATURE: Admins have now access to JSON download links in many places
* FEATURE: Users equipped with related permissions can toggle "Show SQL" in the GUI
### Import and Sync
* FIX: Sync is very powerful and allows for actions not available in the GUI. It
however allowed to store invalid single Service Objects with no Host. This is
now illegal, as it never makes any sense
1.4.1
-----
### Fixed issues

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Director\Objects;
use Icinga\Data\Filter\Filter;
use Icinga\Exception\IcingaException;
use Icinga\Exception\ProgrammingError;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\Data\PropertiesFilter;
@ -516,4 +517,17 @@ class IcingaService extends IcingaObject
return $properties;
}
protected function beforeStore()
{
parent::beforeStore();
if ($this->isObject()
&& $this->get('service_set_id') === null
&& $this->get('host_id') === null
) {
throw new IcingaException(
'Cannot store a Service object without a related host'
);
}
}
}