mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
Log warning when integer is set to invalid value
This commit is contained in:
@@ -2735,7 +2735,7 @@ class AttributeDBFieldVoid extends AttributeDefinition
|
|||||||
public function GetPrerequisiteAttributes($sClass = null)
|
public function GetPrerequisiteAttributes($sClass = null)
|
||||||
{
|
{
|
||||||
$aPrerequisiteAttributes = $this->Get("depends_on");
|
$aPrerequisiteAttributes = $this->Get("depends_on");
|
||||||
if($this->HasParam('expression')) {
|
if($this->IsComputed()) {
|
||||||
$aPrerequisiteAttributes = array_merge($aPrerequisiteAttributes, $this->GetComputedPrerequisiteAttributes());
|
$aPrerequisiteAttributes = array_merge($aPrerequisiteAttributes, $this->GetComputedPrerequisiteAttributes());
|
||||||
}
|
}
|
||||||
return $aPrerequisiteAttributes;
|
return $aPrerequisiteAttributes;
|
||||||
@@ -2983,14 +2983,12 @@ class AttributeInteger extends AttributeDBField
|
|||||||
|
|
||||||
public function MakeRealValue($proposedValue, $oHostObj)
|
public function MakeRealValue($proposedValue, $oHostObj)
|
||||||
{
|
{
|
||||||
if (is_null($proposedValue))
|
if (is_null($proposedValue) || $proposedValue === '')
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
} elseif(gettype($proposedValue) !== 'integer') {
|
||||||
|
IssueLog::Warning("Trying to set integer attribute ".$this->GetCode()." to type".gettype($proposedValue)".");
|
||||||
}
|
}
|
||||||
if ($proposedValue === '')
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
} // 0 is transformed into '' !
|
|
||||||
|
|
||||||
return (int)$proposedValue;
|
return (int)$proposedValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -706,10 +706,10 @@ abstract class DBObject implements iDisplay
|
|||||||
}
|
}
|
||||||
$this->_Set($sAttCode, $realvalue);
|
$this->_Set($sAttCode, $realvalue);
|
||||||
|
|
||||||
$this->UpdateMetaAttributes(array($sAttCode));
|
|
||||||
|
|
||||||
$this->UpdateDependentComputedAttributes($sAttCode);
|
$this->UpdateDependentComputedAttributes($sAttCode);
|
||||||
|
|
||||||
|
$this->UpdateMetaAttributes(array($sAttCode));
|
||||||
|
|
||||||
// The object has changed, reset caches
|
// The object has changed, reset caches
|
||||||
$this->m_bCheckStatus = null;
|
$this->m_bCheckStatus = null;
|
||||||
|
|
||||||
@@ -7001,6 +7001,7 @@ abstract class DBObject implements iDisplay
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
* @throws OQLException
|
* @throws OQLException
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function UpdateDependentComputedAttributes(string $sAttCode): void
|
private function UpdateDependentComputedAttributes(string $sAttCode): void
|
||||||
{
|
{
|
||||||
@@ -7008,7 +7009,11 @@ abstract class DBObject implements iDisplay
|
|||||||
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sCode);
|
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sCode);
|
||||||
if ($oAttDef->IsComputed()) {
|
if ($oAttDef->IsComputed()) {
|
||||||
$oExpression = Expression::FromOQL($oAttDef->GetParams()['expression']);
|
$oExpression = Expression::FromOQL($oAttDef->GetParams()['expression']);
|
||||||
$this->_Set($sCode, $this->EvaluateExpression($oExpression));
|
$value = $this->EvaluateExpression($oExpression);
|
||||||
|
$aAllowedValues = $oAttDef->GetAllowedValues();
|
||||||
|
if(is_null($aAllowedValues) || in_array($value, $aAllowedValues)) {
|
||||||
|
$this->_Set($sCode, $oAttDef->MakeRealValue($value, $this));
|
||||||
|
} ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2661,6 +2661,7 @@ abstract class MetaModel
|
|||||||
*/
|
*/
|
||||||
public static function GetAttributeFlags($sClass, $sState, $sAttCode)
|
public static function GetAttributeFlags($sClass, $sState, $sAttCode)
|
||||||
{
|
{
|
||||||
|
$iFlags = 0;
|
||||||
if (self::HasLifecycle($sClass)) {
|
if (self::HasLifecycle($sClass)) {
|
||||||
$aStates = MetaModel::EnumStates($sClass);
|
$aStates = MetaModel::EnumStates($sClass);
|
||||||
if (!array_key_exists($sState, $aStates)) {
|
if (!array_key_exists($sState, $aStates)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user