Fix stale state issues in RelationCounterField when deleting models.

Review Request #9231 — Created Sept. 28, 2017 and submitted

Christian Hammond

RelationCounterField keeps track of each model instance that contain
references to other models, in order to bump their counter fields, and
it tries to notice when a new instance of a model has claimed the same
ID as an old one (for use in test suites). However, it only worked when
the old instances fell out of scope, and not when they were deleted
(which resets the ID to None and prevents a later lookup from

The field now tracks the pre_delete signal for the instance, taking
care to reset state and untrack the instance. It also clears up signal
handlers, ensuring we don't have any stale ones sitting around.

Unit tests have been added for these fixes.

Verified that the new unit tests failed before this fix, and pass

Ran the Review Board test suite (with an upcoming change), which was
failing. It now passes after this.

  • 0
  • 0
  • 2
  • 0
  • 2
Description From Last Updated
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.


David Trowbridge
  1. Ship It!
Christian Hammond
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.10.x (2741147)