mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #2557 from rchavik/2.4-save-tree-invalid-scope
2.4 save tree invalid scope
This commit is contained in:
commit
b682732c1e
2 changed files with 24 additions and 1 deletions
|
@ -212,7 +212,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
'fields' => array($Model->primaryKey, $parent, $left, $right), 'recursive' => $recursive)
|
||||
);
|
||||
|
||||
if ($values === false) {
|
||||
if (empty($values)) {
|
||||
return false;
|
||||
}
|
||||
list($node) = array_values($values);
|
||||
|
|
|
@ -130,6 +130,29 @@ class TreeBehaviorScopedTest extends CakeTestCase {
|
|||
$this->assertEquals(11, $this->Tree->find('count'));
|
||||
}
|
||||
|
||||
/**
|
||||
* testSaveWithParentAndInvalidScope method
|
||||
*
|
||||
* Attempting to save an invalid data should not trigger an `Undefined offset`
|
||||
* error
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSaveWithParentAndInvalidScope() {
|
||||
$this->Tree = new FlagTree();
|
||||
$this->Tree->order = null;
|
||||
$data = $this->Tree->create(array(
|
||||
'name' => 'Flag',
|
||||
));
|
||||
$tree = $this->Tree->save($data);
|
||||
$this->Tree->Behaviors->load('Tree', array(
|
||||
'scope' => array('FlagTree.flag' => 100)
|
||||
));
|
||||
$tree['FlagTree']['parent_id'] = 1;
|
||||
$result = $this->Tree->save($tree);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testMoveUpWithScope method
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue