Type casting conditions array to avoid warning during array merge in Model::_deleteDependent(). Fixes #477

This commit is contained in:
ADmad 2010-03-18 02:51:20 +05:30
parent 93ac79d4fb
commit 6a723bb515
3 changed files with 14 additions and 3 deletions

View file

@ -1847,7 +1847,7 @@ class Model extends Overloadable {
$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 file

@ -157,6 +157,7 @@ class ModelDeleteTest extends BaseModelTest {
$this->loadFixtures('Cd','Book','OverallFavorite');
$Cd =& new Cd();
$Book =& new Book();
$OverallFavorite =& new OverallFavorite();
$Cd->delete(1);
@ -174,6 +175,16 @@ class ModelDeleteTest extends BaseModelTest {
$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 file

@ -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\''));
}
/**