Skip to content
This repository
Browse code

cascade false for recover

  • Loading branch information...
commit 354069d22995ded6564f9c7ff94c4bf8dd978e97 1 parent 22f65f7
Mark authored November 13, 2012
4  lib/Cake/Model/Behavior/TreeBehavior.php
@@ -622,9 +622,9 @@ public function recover(Model $Model, $mode = 'parent', $missingParentAction = n
622 622
 					}
623 623
 					return false;
624 624
 				} elseif ($missingParentAction === 'delete') {
625  
-					$Model->deleteAll(array($Model->alias . '.' . $Model->primaryKey => array_flip($missingParents)));
  625
+					$Model->deleteAll(array($Model->escapeField($Model->primaryKey) => array_flip($missingParents)), false);
626 626
 				} else {
627  
-					$Model->updateAll(array($parent => $missingParentAction), array($Model->escapeField($Model->primaryKey) => array_flip($missingParents)));
  627
+					$Model->updateAll(array($Model->escapeField($parent) => $missingParentAction), array($Model->escapeField($Model->primaryKey) => array_flip($missingParents)));
628 628
 				}
629 629
 			}
630 630
 			$count = 1;
31  lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php
@@ -183,19 +183,19 @@ public function testRecoverUsingParentMode() {
183 183
 		$this->Tree = new $modelClass();
184 184
 		$this->Tree->Behaviors->disable('Tree');
185 185
 
186  
-		$this->Tree->save(array('parent_id' => null, 'name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
  186
+		$this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
187 187
 		$node1 = $this->Tree->id;
188 188
 
189 189
 		$this->Tree->create();
190  
-		$this->Tree->save(array('parent_id' => null, 'name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0));
  190
+		$this->Tree->save(array('name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0));
191 191
 		$node11	= $this->Tree->id;
192 192
 		$this->Tree->create();
193  
-		$this->Tree->save(array('parent_id' => null, 'name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0));
  193
+		$this->Tree->save(array('name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0));
194 194
 		$node12	= $this->Tree->id;
195 195
 		$this->Tree->create();
196  
-		$this->Tree->save(array('parent_id' => null, 'name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0));
  196
+		$this->Tree->save(array('name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0));
197 197
 		$this->Tree->create();
198  
-		$this->Tree->save(array('parent_id' => null, 'name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0));
  198
+		$this->Tree->save(array('name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0));
199 199
 
200 200
 		$this->Tree->Behaviors->enable('Tree');
201 201
 
@@ -234,24 +234,33 @@ public function testRecoverUsingParentModeAndDelete() {
234 234
 		$this->Tree = new $modelClass();
235 235
 		$this->Tree->Behaviors->disable('Tree');
236 236
 
237  
-		$this->Tree->save(array('parent_id' => null, 'name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
  237
+		$this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
238 238
 		$node1 = $this->Tree->id;
239 239
 
240 240
 		$this->Tree->create();
241  
-		$this->Tree->save(array('parent_id' => null, 'name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0));
  241
+		$this->Tree->save(array('name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0));
242 242
 		$node11	= $this->Tree->id;
243 243
 		$this->Tree->create();
244  
-		$this->Tree->save(array('parent_id' => null, 'name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0));
  244
+		$this->Tree->save(array('name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0));
245 245
 		$node12	= $this->Tree->id;
246 246
 		$this->Tree->create();
247  
-		$this->Tree->save(array('parent_id' => null, 'name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0));
  247
+		$this->Tree->save(array('name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0));
248 248
 		$this->Tree->create();
249  
-		$this->Tree->save(array('parent_id' => null, 'name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0));
  249
+		$this->Tree->save(array('name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0));
250 250
 		$this->Tree->create();
251  
-		$this->Tree->save(array('parent_id' => null, 'name' => 'Lost', $parentField => 9, $leftField => 0, $rightField => 0));
  251
+		$this->Tree->save(array('name' => 'Lost', $parentField => 9, $leftField => 0, $rightField => 0));
252 252
 
253 253
 		$this->Tree->Behaviors->enable('Tree');
254 254
 
  255
+		$this->Tree->bindModel(array('belongsTo' => array('Parent' => array(
  256
+			'className' => $this->Tree->name,
  257
+			'foreignKey' => $parentField
  258
+		))));
  259
+		$this->Tree->bindModel(array('hasMany' => array('Child' => array(
  260
+			'className' => $this->Tree->name,
  261
+			'foreignKey' => $parentField
  262
+		))));
  263
+
255 264
 		$result = $this->Tree->verify();
256 265
 		$this->assertNotSame($result, true);
257 266
 

0 notes on commit 354069d

Please sign in to comment.
Something went wrong with that request. Please try again.