Skip to content
Permalink
Browse files

Restore whitelist when save fails.

Fixes whitelist not being restored when save fails due to no data.

Fixes #3646
  • Loading branch information...
markstory committed Feb 26, 2013
1 parent 3d0920a commit 33bd7a571a0c5e02327f72c50eed386b2e242ce5
Showing with 17 additions and 0 deletions.
  1. +1 −0 lib/Cake/Model/Model.php
  2. +16 −0 lib/Cake/Test/Case/Model/ModelWriteTest.php
@@ -1626,6 +1626,7 @@ public function save($data = null, $validate = true, $fieldList = array()) {
$this->set($data);
if (empty($this->data) && !$this->hasField(array('created', 'updated', 'modified'))) {
$this->whitelist = $_whitelist;
return false;
}
@@ -275,6 +275,22 @@ public function testCacheClearOnSave() {
Configure::write('Cache.disable', $_back['disable']);
}
/**
* test that save() resets whitelist on failed save
*/
public function testSaveFieldListResetsWhitelistOnFailedSave() {
$this->loadFixtures('Bidding');
$model = new Bidding();
$whitelist = array('title');
$model->whitelist = $whitelist;
$result = $model->save(
array(),
array('fieldList' => array('body'))
);
$this->assertFalse($result);
$this->assertEquals($whitelist, $model->whitelist);
}
/**
* testSaveWithCounterCache method
*

0 comments on commit 33bd7a5

Please sign in to comment.
You can’t perform that action at this time.