yiisoft / yiisoft/active-record
ActiveRecord unlink() not applying events/behaviors on junction model - inconsistent with link()
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 119
- Forks
- 38
- Avg merge
- 1h 11m
- Merged PRs (30d)
- 1
Description
When declaring a 'via' (not 'viaTable') relation the respsective behaviors of link() vs unlink() are a bit inconsistent.
link() will trigger events and use behaviors on the junction model provided by the 'via' modelClass while unlink() will not.
I think it is really awesome that link() uses insert() on the junction model, but conversely unlink() should also use delete() on the junction model.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the ActiveRecord relation handling for unlink() when a via modelClass is used, and compare it with link() and the viaTable path. Verify how the junction model is created through insert() in link(), then confirm that unlink() removes it through delete() so its events and behaviors are applied.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100