Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Type casting conditions array to avoid warning during array merge in …

…Model::_deleteDependent(). Fixes #477
  • Loading branch information...
commit 6a723bb515e8a53578f6c24f21fcbbaf1790c7ba 1 parent 93ac79d
@ADmad ADmad authored
View
2  cake/libs/model/model.php
@@ -1847,7 +1847,7 @@ function _deleteDependent($id, $cascade) {
$model =& $this->{$assoc};
$conditions = array($model->escapeField($data['foreignKey']) => $id);
if ($data['conditions']) {
- $conditions = array_merge($data['conditions'], $conditions);
+ $conditions = array_merge((array)$data['conditions'], $conditions);
}
$model->recursive = -1;
View
11 cake/tests/cases/libs/model/model_delete.test.php
@@ -157,6 +157,7 @@ function testDeleteDependentWithConditions() {
$this->loadFixtures('Cd','Book','OverallFavorite');
$Cd =& new Cd();
+ $Book =& new Book();
$OverallFavorite =& new OverallFavorite();
$Cd->delete(1);
@@ -174,6 +175,16 @@ function testDeleteDependentWithConditions() {
$this->assertTrue(is_array($result));
$this->assertEqual($result, $expected);
+
+ $Book->delete(1);
+
+ $result = $OverallFavorite->find('all', array(
+ 'fields' => array('model_type', 'model_id', 'priority')
+ ));
+ $expected = array();
+
+ $this->assertTrue(is_array($result));
+ $this->assertEqual($result, $expected);
}
/**
View
4 cake/tests/cases/libs/model/models.php
@@ -2025,7 +2025,7 @@ class AssociationTest2 extends CakeTestModel {
* @subpackage cake.tests.cases.libs.model
*/
class Callback extends CakeTestModel {
-
+
}
/**
* CallbackPostTestModel class
@@ -2445,7 +2445,7 @@ class Book extends CakeTestModel {
* @var array
* @access public
*/
- var $hasOne = array('OverallFavorite' => array('foreignKey' => 'model_id', 'dependent' => true, 'conditions' => array('model_type' => 'Book')));
+ var $hasOne = array('OverallFavorite' => array('foreignKey' => 'model_id', 'dependent' => true, 'conditions' => 'OverallFavorite.model_type = \'Book\''));
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.