Skip to content

Commit

Permalink
Unify modified/created times
Browse files Browse the repository at this point in the history
The former implementation meant that it was not guarantee that
the times automatically generated for the modified/created fields
would be exactly the same for a given operation.
  • Loading branch information
Thom Seddon committed Jun 12, 2013
1 parent bbcc7b2 commit 305b3f4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Cake/Model/Model.php
Expand Up @@ -1662,13 +1662,14 @@ public function save($data = null, $validate = true, $fieldList = array()) {
}

$db = $this->getDataSource();
$now = time();

foreach ($dateFields as $updateCol) {
if ($this->hasField($updateCol) && !in_array($updateCol, $fields)) {
$default = array('formatter' => 'date');
$colType = array_merge($default, $db->columns[$this->getColumnType($updateCol)]);
if (!array_key_exists('format', $colType)) {
$time = strtotime('now');
$time = $now;
} else {
$time = call_user_func($colType['formatter'], $colType['format']);
}
Expand Down

0 comments on commit 305b3f4

Please sign in to comment.