Permalink
Browse files

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

…Model::_deleteDependent(). Fixes #477
  • Loading branch information...
1 parent 93ac79d commit 6a723bb515e8a53578f6c24f21fcbbaf1790c7ba @ADmad ADmad committed Mar 17, 2010
@@ -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;
@@ -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);
}
/**
@@ -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\''));
}
/**

0 comments on commit 6a723bb

Please sign in to comment.