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:
Romain Quetiez
2016-09-30 14:22:13 +00:00
parent 97d11ba910
commit 5336d9e965

View File

@@ -3811,6 +3811,17 @@ class AttributeDateTime extends AttributeDBField
}
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;
}