Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

avoid warning when saveAll() data has empty hasMany data, fixes #2792

  • Loading branch information...
commit a84597784d184c782f53e77abf6b85cf90ca85a6 1 parent 9556ff7
@ceeram ceeram authored
View
6 lib/Cake/Model/Model.php
@@ -2036,6 +2036,9 @@ public function saveMany($data = null, $options = array()) {
if (empty($data) && $options['validate'] !== false) {
$result = $this->save($data, $options);
+ if (!$options['atomic']) {
+ return array(!empty($result));
+ }
return !empty($result);
}
@@ -2167,6 +2170,9 @@ public function saveAssociated($data = null, $options = array()) {
if (empty($data) && $options['validate'] !== false) {
$result = $this->save($data, $options);
+ if (!$options['atomic']) {
+ return array(!empty($result));
+ }
return !empty($result);
}
View
16 lib/Cake/Test/Case/Model/ModelWriteTest.php
@@ -5229,6 +5229,22 @@ public function testSaveAssociatedHasMany() {
}
/**
+ * testSaveAssociatedHasManyEmpty method
+ *
+ * @return void
+ */
+ public function testSaveAssociatedHasManyEmpty() {
+ $this->loadFixtures('Article', 'Comment');
+ $TestModel = new Article();
+ $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
+ $result = $TestModel->saveAssociated(array(
+ 'Article' => array('title' => 'title', 'author_id' => 1),
+ 'Comment' => array()
+ ), array('validate' => true));
+ $this->assertTrue($result);
+ }
+
+/**
* testSaveAssociatedHasManyValidation method
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.