Skip to content

Commit

Permalink
fix/notification-command-inherited-fields-missing refs Icinga#2286
Browse files Browse the repository at this point in the history
  • Loading branch information
moreamazingnick authored Jun 12, 2023
1 parent abbf580 commit b401bb9
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions library/Director/Web/Form/IcingaObjectFieldLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,27 +421,32 @@ protected function prepareObjectFields($object)
{
$fields = $this->loadResolvedFieldsForObject($object);
if ($object->hasRelation('check_command')) {
try {
/** @var IcingaCommand $command */
$command = $object->getResolvedRelated('check_command');
} catch (Exception $e) {
// Ignore failures
$command = null;
}

if ($command) {
$cmdLoader = new static($command);
$cmdFields = $cmdLoader->getFields();
foreach ($cmdFields as $varname => $field) {
if (! array_key_exists($varname, $fields)) {
$fields[$varname] = $field;
}
#for checks
$relation = "check_command";
} elseif ($object->hasRelation('command')) {
#for notifications
$relation = "command";
}

try {
/** @var IcingaCommand $command */
$command = $object->getResolvedRelated($relation);
} catch (Exception $e) {
// Ignore failures
$command = null;
}

if ($command) {
$cmdLoader = new static($command);
$cmdFields = $cmdLoader->getFields();
foreach ($cmdFields as $varname => $field) {
if (!array_key_exists($varname, $fields)) {
$fields[$varname] = $field;
}
}

// TODO -> filters!
}


// TODO -> filters!
return $fields;
}

Expand Down

0 comments on commit b401bb9

Please sign in to comment.