mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixed bug in Model::__save validation logic, closes #4554
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6824 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
232e3f7ec1
commit
823eb81dc7
2 changed files with 18 additions and 1 deletions
|
@ -1428,7 +1428,7 @@ class Model extends Overloadable {
|
|||
*/
|
||||
function __save(&$model, $data, $options) {
|
||||
if ($options['validate'] === 'first' || $options['validate'] === 'only') {
|
||||
if (!($model->create($data) && $this->validates())) {
|
||||
if (!($model->create($data) && $model->validates())) {
|
||||
return false;
|
||||
}
|
||||
} elseif (!($model->create(null) !== null && $model->save($data, $options))) {
|
||||
|
|
|
@ -2321,6 +2321,23 @@ class ModelTest extends CakeTestCase {
|
|||
$this->model->validate['body'] = VALID_NOT_EMPTY;
|
||||
}
|
||||
|
||||
function testSaveAllValidationOnly() {
|
||||
$this->model =& new Comment();
|
||||
$this->model->Attachment->validate = array('attachment' => VALID_NOT_EMPTY);
|
||||
|
||||
$data = array(
|
||||
'Comment' => array(
|
||||
'comment' => 'This is the comment'
|
||||
),
|
||||
'Attachment' => array(
|
||||
'attachment' => ''
|
||||
)
|
||||
);
|
||||
|
||||
$result = $this->model->saveAll($data, array('validate' => 'only'));
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
function testSaveWithCounterCache() {
|
||||
$this->loadFixtures('Syfile', 'Item');
|
||||
$this->model =& new Syfile();
|
||||
|
|
Loading…
Reference in a new issue