mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-2739: DBAL/Types/DateType bad argument checking #3428
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Oct 13, 2013).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user zephir:
class Entity
{
/****
* @ORM\Column(type="date", nullable=true)
*/
private $date;
}
$entity = new Entity();
$entity->setDate('2013-01-01'); //Fatal error: Call to a member function format() on a non-object in /vendor/doctrine-dbal/lib/Doctrine/DBAL/Types/DateType.php on line 53
$entity->setTime('00:00'); //Fatal error: Call to a member function format() on a non-object in /vendor/doctrine-dbal/lib/Doctrine/DBAL/Types/TimeType.php on line 53
EXPECTED any Exception!!!
https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Types/DateType.php#L50
https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Types/TimeType.php#L52
https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Types/DateTimeType.php#L52
https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Types/DateTimeTzType.php#L70
@doctrinebot commented on GitHub (Oct 16, 2013):
Comment created by @ocramius:
You didn't put a correct type hint on your setters:
That's how you are supposed to use the date types.
@doctrinebot commented on GitHub (Oct 16, 2013):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Oct 22, 2013):
Comment created by da-eto:
Hm. Yes, type hint is simple way to achive desired behavior.
But fatal error from core application component such as Doctrine is very annoying.
Maybe Doctrine should throw exception on type mismatch rather than fatal error?
@doctrinebot commented on GitHub (Oct 22, 2013):
Comment created by @ocramius:
[~da-eto] no, that's really something that is called thousands of times per request. I wouldn't introduce a check there.