DirectorObjectForm: deal with "no template"...

...when fetching Choices

fixes #2268
This commit is contained in:
Thomas Gelf 2021-01-21 11:25:23 +01:00
parent 21a284abbc
commit e2a8886148
1 changed files with 9 additions and 5 deletions

View File

@ -1184,11 +1184,15 @@ abstract class DirectorObjectForm extends DirectorForm
$choices = IcingaObject::loadAllByType($choiceType, $connection);
$chosenTemplates = $this->getSentOrObjectValue('imports');
$db = $connection->getDbAdapter();
$importedIds = $db->fetchCol(
$db->select()->from($table, 'id')
->where('object_name in (?)', (array)$chosenTemplates)
->where('object_type = ?', 'template')
);
if (empty($chosenTemplates)) {
$importedIds = [];
} else {
$importedIds = $db->fetchCol(
$db->select()->from($table, 'id')
->where('object_name in (?)', (array)$chosenTemplates)
->where('object_type = ?', 'template')
);
}
foreach ($choices as $choice) {
$required = $choice->get('required_template_id');