mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Type casting conditions array to avoid warning during array merge in Model::_deleteDependent(). Fixes #477
This commit is contained in:
parent
93ac79d4fb
commit
6a723bb515
3 changed files with 14 additions and 3 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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\''));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue