mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-02 09:32:43 +00:00
Fixes #3418, Model throws warnings when trying to save an empty array
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5804 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
981b8fed56
commit
5cb63a6460
2 changed files with 13 additions and 0 deletions
|
@ -1048,6 +1048,11 @@ class Model extends Overloadable {
|
|||
}
|
||||
|
||||
$this->set($data);
|
||||
|
||||
if (empty($this->data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (array('created', 'updated', 'modified') as $field) {
|
||||
if (array_key_exists($field, $this->data[$this->name]) && $this->data[$this->name][$field] === null) {
|
||||
unset($this->data[$this->name][$field]);
|
||||
|
|
|
@ -2854,6 +2854,14 @@ class ModelTest extends CakeTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
function testSaveEmpty() {
|
||||
$this->model =& new Article();
|
||||
$data = array();
|
||||
$expected = $this->model->save($data);
|
||||
$this->assertFalse($expected);
|
||||
|
||||
}
|
||||
|
||||
/*function testBasicValidation() {
|
||||
$this->model =& new ValidationTest();
|
||||
$this->model->set(array('title' => '', 'published' => 1));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue