Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0 - ORM: Fatal error saving null datetime #3410

Closed
batopa opened this issue Apr 28, 2014 · 1 comment
Closed

3.0 - ORM: Fatal error saving null datetime #3410

batopa opened this issue Apr 28, 2014 · 1 comment
Assignees
Milestone

Comments

@batopa
Copy link
Contributor

batopa commented Apr 28, 2014

To reproduce:

  • create a table posts with a DATETIME nullable field publication_date

  • in controller try to save null value for that field

    $data['publication_date'] = null;
    $c = TableRegistry::get('Posts');
    $e = $c->newEntity($data);
    $c->save($e);

A fatal error was triggered

Error: Call to a member function format() on a non-object   
File /..../vendor/cakephp/cakephp/src/Database/Type/DateTimeType.php    
Line: 62

Cake\Database\Type\DateTimeType::toDatabase($value, Driver $driver) method doesn't check if $value is null and it tries to use a method on it $value->format($this->_format);

lorenzo added a commit that referenced this issue Apr 28, 2014
lorenzo added a commit that referenced this issue Apr 28, 2014
@lorenzo lorenzo added this to the 3.0.0 milestone Apr 28, 2014
@lorenzo lorenzo self-assigned this Apr 28, 2014
@markstory
Copy link
Member

#3411 has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants