mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
Internal: improved the API robustness by throwing an exception as soon as DBObject::Set is called with a date badly formatted. This is in line with the assumption that internal DBObject values are always safe.
SVN:trunk[4435]
This commit is contained in:
@@ -3811,6 +3811,17 @@ class AttributeDateTime extends AttributeDBField
|
|||||||
}
|
}
|
||||||
if (!is_numeric($proposedValue))
|
if (!is_numeric($proposedValue))
|
||||||
{
|
{
|
||||||
|
// Check the format
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$oFormat = new DateTimeFormat($this->GetInternalFormat());
|
||||||
|
$oTrash = $oFormat->Parse($proposedValue);
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
throw new Exception('Wrong format for date attribute '.$this->GetCode().', expecting "'.$this->GetInternalFormat().'" and got "'.$proposedValue.'"');
|
||||||
|
}
|
||||||
|
|
||||||
return $proposedValue;
|
return $proposedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user