Skip to content

Commit

Permalink
Don't pass validaiton preferences down to associations in Table::save()
Browse files Browse the repository at this point in the history
Fixes #3873
  • Loading branch information
lorenzo committed Jul 5, 2014
1 parent 9b20a21 commit 7ad59c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/ORM/Table.php
Expand Up @@ -1136,8 +1136,9 @@ protected function _processSave($entity, $options) {

$associated = $options['associated'];
$options['associated'] = [];
$validate = $options['validate'];

if ($options['validate'] && !$this->validate($entity, $options)) {
if ($validate && !$this->validate($entity, $options)) {
return false;
}

Expand All @@ -1153,7 +1154,7 @@ protected function _processSave($entity, $options) {
$this,
$entity,
$options['associated'],
$options->getArrayCopy()
['validate' => (bool)$validate] + $options->getArrayCopy()
);

if (!$saved && $options['atomic']) {
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/TableTest.php
Expand Up @@ -2106,7 +2106,7 @@ public function testSaveWithDifferentValidatorAndAssociations() {
$this->assertFalse($table->save($entity, ['validate' => 'custom']));
$this->assertNotEmpty($entity->author->errors('thing'));

$this->assertSame($entity, $table->save($entity), 'default was not used');
$this->assertFalse($table->save($entity), 'default was not used');
}

/**
Expand Down

0 comments on commit 7ad59c9

Please sign in to comment.