N°2847 - Fix crash when object with state attribute has no state defined

This commit is contained in:
Molkobain
2020-11-10 15:55:20 +01:00
parent 38fbc49e51
commit 77ecd055b4
2 changed files with 10 additions and 6 deletions

View File

@@ -53,11 +53,15 @@ class TitleFactory
}
if (MetaModel::HasStateAttributeCode($sObjClass)) {
$sStatusAttCode = MetaModel::GetStateAttributeCode($sObjClass);
$sStateCode = $oObject->GetState();
$sStatusLabel = $oObject->GetStateLabel();
$sStatusColor = UIHelper::GetColorFromStatus(get_class($oObject), $sStateCode);
$oTitle->SetStatus($sStatusAttCode, $sStatusLabel, $sStatusColor);
// Protection against classes with no default state (in which case we don't display the status)
if(!empty($sStateCode)) {
$sStatusAttCode = MetaModel::GetStateAttributeCode($sObjClass);
$sStatusLabel = $oObject->GetStateLabel();
$sStatusColor = UIHelper::GetColorFromStatus(get_class($oObject), $sStateCode);
$oTitle->SetStatus($sStatusAttCode, $sStatusLabel, $sStatusColor);
}
}
return $oTitle;