mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Making saveAll() behave like plain save() when suplied empty data array, closes #277
This commit is contained in:
parent
8375570f8a
commit
5c186d4430
2 changed files with 23 additions and 0 deletions
|
@ -1584,6 +1584,11 @@ class Model extends Overloadable {
|
||||||
$validates = true;
|
$validates = true;
|
||||||
$return = array();
|
$return = array();
|
||||||
|
|
||||||
|
if (empty($data) && $options['validate'] !== false) {
|
||||||
|
$result = $this->save($data, $options);
|
||||||
|
return !empty($result);
|
||||||
|
}
|
||||||
|
|
||||||
if ($options['atomic'] && $options['validate'] !== 'only') {
|
if ($options['atomic'] && $options['validate'] !== 'only') {
|
||||||
$db->begin($this);
|
$db->begin($this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3798,6 +3798,24 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->assertEqual($resultsFkFalse, $expected);
|
$this->assertEqual($resultsFkFalse, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that saveAll behaves like plain save() when suplied empty data
|
||||||
|
*
|
||||||
|
* @link http://cakephp.lighthouseapp.com/projects/42648/tickets/277-test-saveall-with-validation-returns-incorrect-boolean-when-saving-empty-data
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testSaveAllEmptyData() {
|
||||||
|
$this->loadFixtures('Article', 'ProductUpdateAll');
|
||||||
|
$model =& new Article();
|
||||||
|
$result = $model->saveAll(array(), array('validate' => 'first'));
|
||||||
|
$this->assertTrue($result);
|
||||||
|
|
||||||
|
$model =& new ProductUpdateAll();
|
||||||
|
$result = $model->saveAll(array());
|
||||||
|
$this->assertFalse($result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue