Skip to content

Commit

Permalink
Modify _updateField to check using immutable-datetimetype
Browse files Browse the repository at this point in the history
  • Loading branch information
o0h committed Dec 31, 2017
1 parent 31e7331 commit 896c6f2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/ORM/Behavior/TimestampBehavior.php
Expand Up @@ -14,6 +14,7 @@
*/
namespace Cake\ORM\Behavior;

use Cake\Database\Type;
use Cake\Datasource\EntityInterface;
use Cake\Event\Event;
use Cake\I18n\Time;
Expand Down Expand Up @@ -193,6 +194,14 @@ protected function _updateField($entity, $field, $refreshTimestamp)
if ($entity->isDirty($field)) {
return;
}
$entity->set($field, $this->timestamp(null, $refreshTimestamp));

$ts = $this->timestamp(null, $refreshTimestamp);

$columnType = $this->getTable()->getSchema()->getColumnType($field);
/** @var \Cake\Database\Type\DateTimeType $type */
$type = Type::build($columnType);
$class = $type->getDateTimeClassName();

$entity->set($field, new $class($ts));
}
}

0 comments on commit 896c6f2

Please sign in to comment.