Fixes for background updates that break form validation for documents#3092
Merged
longhotsummer merged 8 commits intomainfrom Mar 19, 2026
Merged
Fixes for background updates that break form validation for documents#3092longhotsummer merged 8 commits intomainfrom
longhotsummer merged 8 commits intomainfrom
Conversation
otherwise the images formset breaks if images change underneath the editor due to background tasks
Test Results32 tests - 354 32 ✅ - 344 0s ⏱️ -26s Results for commit a1393d8. ± Comparison against base commit 4273083. This pull request removes 356 and adds 2 tests. Note that renamed tests count towards both. |
| # there is a small race condition here if SourceFile is created in the db while we do this. In that case | ||
| # the task will fail and be re-tried. | ||
| source_file = getattr(doc, "source_file", None) or SourceFile(document=doc) | ||
| source_file.track_changes() |
Contributor
There was a problem hiding this comment.
Okay I understand it now....I think. A bad interaction between SourceFile's base class and the Lifecycle library, led to the weird behaviour.
Since the fix is the AttributeHooksMixin; Does this mean for classes that inherit it, they have to call track_changes() every time they want the hooks to fire, for all cases?
Contributor
Author
There was a problem hiding this comment.
Classes that use AttributeHooksMixin must call track_changes() to setup change tracking, yes. So it's opt-in.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are a couple of changes here:
filehad changed whenever it was saved, which triggered background updates. So this changes SourceFile to be opt-in to change tracking usingtrack_changes()