Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion application/cmdbabstract.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3240,7 +3240,13 @@ public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormPar
$aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs);
if (is_array($aAllowedValues) && count($aAllowedValues) == 1) {
$aValues = array_keys($aAllowedValues);
$this->Set($sAttCode, $aValues[0]);
if ($oAttDef->IsLinkSet()) {
$oObjectSet = $this->Get($sAttCode);
$oObjectSet->AddItem(MetaModel::GetObject($oAttDef->GetLinkedClass(), $aValues[0]));
$this->Set($sAttCode, $oObjectSet);
Comment on lines +3243 to +3246
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Indirect linksets misload objects

For an AttributeLinkedSetIndirect, GetAllowedValues_att() returns ids from the remote target class, because AttributeLinkedSet::GetValuesDef() uses LinkSetModel::GetTargetClass(). This branch then loads that id from $oAttDef->GetLinkedClass(), which is the link/intermediate class. When a lifecycle transition has exactly one allowed remote object, the form can throw because no link row has that id, or it can add an unrelated existing link row with the same numeric id. The indirect case needs to create a link object and set its remote external key instead of loading the link class by the remote id.

} else {
$this->Set($sAttCode, $aValues[0]);
}
}
}
}
Expand Down