mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Restore whitelist when save fails.
Fixes whitelist not being restored when save fails due to no data. Fixes #3646
This commit is contained in:
parent
3d0920a405
commit
33bd7a571a
2 changed files with 17 additions and 0 deletions
|
@ -1626,6 +1626,7 @@ class Model extends Object implements CakeEventListener {
|
|||
$this->set($data);
|
||||
|
||||
if (empty($this->data) && !$this->hasField(array('created', 'updated', 'modified'))) {
|
||||
$this->whitelist = $_whitelist;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -275,6 +275,22 @@ class ModelWriteTest extends BaseModelTest {
|
|||
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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue