diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 950f61418..0c59a2f17 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -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; diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php index da31145ca..c09f9bed2 100644 --- a/cake/tests/cases/libs/model/model.test.php +++ b/cake/tests/cases/libs/model/model.test.php @@ -2150,16 +2150,16 @@ class ModelTest extends CakeTestCase { ); $ts = date('Y-m-d H:i:s'); $this->assertTrue($this->model->saveAll($data)); - + $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)) ); $this->assertEqual($result, $expected); - + $this->model->validate = array('title' => VALID_NOT_EMPTY, 'author_id' => 'numeric'); $data = array( array('id' => '1', 'title' => 'Un-Baleeted First Post', 'body' => 'Not Baleeted!', 'published' => 'Y'),