Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Restore whitelist when save fails.

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

Fixes #3646
  • Loading branch information...
commit 33bd7a571a0c5e02327f72c50eed386b2e242ce5 1 parent 3d0920a
@markstory markstory authored
View
1  lib/Cake/Model/Model.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;
}
View
16 lib/Cake/Test/Case/Model/ModelWriteTest.php
@@ -276,6 +276,22 @@ public function testCacheClearOnSave() {
}
/**
+ * 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
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.