AO3-6531 Fix comment decorator 500 error for orphaned comments#5719
Open
pmonfort wants to merge 2 commits intootwcode:masterfrom
Open
AO3-6531 Fix comment decorator 500 error for orphaned comments#5719pmonfort wants to merge 2 commits intootwcode:masterfrom
pmonfort wants to merge 2 commits intootwcode:masterfrom
Conversation
f37f8de to
a6b8fe4
Compare
3fb5cde to
50c3d3e
Compare
50c3d3e to
c4f3b3f
Compare
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.
Pull Request Checklist
as the first thing in your pull request title (e.g.
AO3-1234 Fix thing)until they are reviewed and merged before creating new pull requests.
Issue
https://otwarchive.atlassian.net/browse/AO3-6531
Purpose
Fixes a 500 error in
CommentDecorator.from_thread_idscaused by orphaned comments — replies whose parent comment was physically removed fromthe database (via
.delete) rather than soft-deleted.When building the comment tree, the decorator looks up each reply's parent in a hash by
commentable_id. If the parent was physically deleted,the lookup returns
nil, causing aNoMethodError. The fix adds a nil check so that orphaned replies are silently skipped when building thetree, rather than crashing the page.
Additionally, this PR includes a rake task
After:create_placeholders_for_orphaned_commentsthat finds all orphaned comments in thedatabase and creates soft-deleted placeholder comments in their place. The task:
threaded_left) to handle cases where multiple comments were deleted in the same branchTesting Instructions
Comment.find(id).delete)bundle exec rake After:create_placeholders_for_orphaned_commentsCredit
Pablo Monfort (he/him)