yiisoft / yiisoft/active-record

ActiveRecord unlink() not applying events/behaviors on junction model - inconsistent with link()

Open
#37 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.