Hi there. I found a bug (not sure its a bug or this is right behavior)
Its somehow connected with relations. When i delete the parent model, related one (with ACTION_CASCADE foreign key) will be deleted too but without conditions/params (if we have). Lets describe well with the example:
My Model
class Musicians extends \Phalcon\Mvc\Model
{
public function initialize()
{
$this->hasMany('id', 'Models\Pictures', 'parent_id', [
'foreignKey' => [
'action' => \Phalcon\Mvc\Model\Relation::ACTION_CASCADE,
],
'alias' => 'Gallery',
'params' => [
'conditions' => 'type={type:str} AND subtype={subtype:str}',
'bind' => [
'type' => get_class($this),
'subtype' => 'gallery'
]
]
]);
}
}
Pictures table columns are (for example): parent_id | type | subtype:
Now if i do this:
$musician = \Models\Musicians::findFirst(1);
$musician->delete();
... will be deleted all records from picture with parent_id=1 (without extended conditions - type and subtype)
Expected behavior
To delete only records with parent_id, type and subtype (together).
Sorry for my English skills. Hope you understand me.
Details
I can verify this, the params option is completely ignored.
The conditions option used here is neither documented, nor used anywhere else. (It should be inside params, but even on its own it wouldn't be enough.)
This is a very high priority bug as the probability of a possible data loss is almost certain.
I am going to fix this ASAP.
U great. Thanks 馃憤
Resolved in #15126