Skip to content

Commit 7ad59c9

Browse files
committed
Don't pass validaiton preferences down to associations in Table::save()
Fixes #3873
1 parent 9b20a21 commit 7ad59c9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/ORM/Table.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,8 +1136,9 @@ protected function _processSave($entity, $options) {
11361136

11371137
$associated = $options['associated'];
11381138
$options['associated'] = [];
1139+
$validate = $options['validate'];
11391140

1140-
if ($options['validate'] && !$this->validate($entity, $options)) {
1141+
if ($validate && !$this->validate($entity, $options)) {
11411142
return false;
11421143
}
11431144

@@ -1153,7 +1154,7 @@ protected function _processSave($entity, $options) {
11531154
$this,
11541155
$entity,
11551156
$options['associated'],
1156-
$options->getArrayCopy()
1157+
['validate' => (bool)$validate] + $options->getArrayCopy()
11571158
);
11581159

11591160
if (!$saved && $options['atomic']) {

tests/TestCase/ORM/TableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ public function testSaveWithDifferentValidatorAndAssociations() {
21062106
$this->assertFalse($table->save($entity, ['validate' => 'custom']));
21072107
$this->assertNotEmpty($entity->author->errors('thing'));
21082108

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

21122112
/**

0 commit comments

Comments
 (0)