Correcting issue in Model::__save() to prevent overwriting of existing record data

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6700 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-04-19 13:30:11 +00:00
parent f34ae31184
commit 16bfee9831
2 changed files with 4 additions and 4 deletions

View file

@ -1426,7 +1426,7 @@ class Model extends Overloadable {
if (!($model->create($data) && $this->validates())) {
return false;
}
} elseif (!($model->create($data) && $model->save(null, $options))) {
} elseif (!($model->create(null) !== null && $model->save($data, $options))) {
return false;
}
return true;

View file

@ -2154,7 +2154,7 @@ class ModelTest extends CakeTestCase {
$result = $this->model->find('all', array('recursive' => -1));
$expected = array(
array('Post' => array('id' => '1', 'author_id' => '1', 'title' => 'Baleeted First Post', 'body' => 'Baleeted!', 'published' => 'N', 'created' => '2007-03-18 10:39:23', 'updated' => $ts)),
array('Post' => array('id' => '2', 'author_id' => '3', 'title' => 'Just update the title', 'body' => 'Second Post Body', 'published' => 'N', 'created' => '2007-03-18 10:41:23', 'updated' => $ts)),
array('Post' => array('id' => '2', 'author_id' => '3', 'title' => 'Just update the title', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => $ts)),
array('Post' => array('id' => '3', 'author_id' => '1', 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31')),
array('Post' => array('id' => '4', 'author_id' => '2', 'title' => 'Creating a fourth post', 'body' => 'Fourth post body', 'published' => 'N', 'created' => $ts, 'updated' => $ts))
);