mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-27 13:45:29 +08:00
Requesting `/t/slug/id?page=N` with a page number beyond the topic's last valid page raised `Discourse::NotFound` and returned 404. This produced a long-running stream of "increase in 404 errors" reports in Google Search Console, because crawlers (and our own `sitemap_recent.xml`) hold cached page URLs that become stale when a topic shrinks — most often after deleted posts or topic splits. The 404 also masked a latent bug for staff: the original check compared the requested page against `topic.posts_count`, a cached column that excludes whispers and ignores active filters (`username_filters`, `replies_to_post_number`, etc.). A staff user navigating to `?page=N` covering whisper posts could be 404'd even though the page contained content they were entitled to see. Replace the 404 with a 301 redirect to the last valid page (or the unparameterized topic URL if the topic fits in one page), using `@topic_view.filtered_posts.count` — the count of posts visible to the current viewer — so the math respects whispers, deletions visible to staff, and active filters. The COUNT query is gated behind `page > 1` so the common case (no `?page=` param) pays nothing extra. Negative pages still raise 404; only the over-range case becomes a redirect. https://meta.discourse.org/t/96337 |
||
|---|---|---|
| .. | ||
| app | ||
| assets | ||
| config | ||
| db/migrate | ||
| extensions | ||
| lib | ||
| spec | ||
| test/javascripts/acceptance | ||
| package.json | ||
| plugin.rb | ||
| README.md | ||
| tsconfig.json | ||
Discourse Post Voting
Discourse Post Voting allows the creation of topics with votable posts.
Please refer to https://meta.discourse.org/t/227808 for more info!
Contributions
Special thanks to Pavilion for building https://github.com/paviliondev/discourse-question-answer which this plugin took inspirations from.
