mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-25 07:58:07 +08:00
## Summary `NestedReplies::TreeLoader#op_post` loaded the OP via `topic.posts`, whose default scope (from `Trashable`) excludes rows with `deleted_at` set. When a topic is trashed its OP is trashed too, so the lookup returned `nil` and the `/n/...` request crashed in `PostPreloader#prepare` with `undefined method 'user_id' for nil` — preventing staff from reaching the page to recover the topic. Fix: apply the existing visibility helper (which already unscopes `deleted_at`) on the OP query. The serializer's `deleted_post_placeholder` path preserves content for staff and hides it for everyone else, matching the flat topic view. - non-staff still 404 via the earlier guardian check on the topic itself, so this does not change their visibility - both the `show` and `context` endpoints share the same loader, so both paths are fixed ## Test plan - [x] `bin/rspec spec/requests/nested_topics_controller_spec.rb` (100 examples, 0 failures), with new cases for staff `show`, staff `context`, and non-staff 404 on a fully-deleted topic - [x] `bin/rspec spec/lib/nested_replies/ spec/services/nested_topic/` (127 examples, 0 failures) - [ ] Manually: as admin, delete a topic that uses nested replies, then navigate to `/n/<slug>/<id>` — page renders with the deleted OP placeholder and the admin menu's Recover Topic action works |
||
|---|---|---|
| .. | ||
| ancestor_walker.rb | ||
| post_preloader.rb | ||
| post_tree_serializer.rb | ||
| sort.rb | ||
| tree_loader.rb | ||