discourse/plugins/discourse-solved/app
Régis Hanol af870d50f8
FIX: Skip QAPage schema when topic has no visible answers (#38964)
Google Search Console reports acceptedAnswer/suggestedAnswer errors on
topics that emit QAPage structured data with answerCount:0 and neither
field present. This affects single-post topics, topics where the only
replies are hidden or small action posts, and topics whose accepted
answer has been hidden.

The fix introduces two checks:

1. A `has_eligible_answers?` query in SchemaUtils that verifies at least
one visible, regular-type reply exists before emitting QAPage schema
(both JSON-LD and microdata). Topics without eligible answers fall back
to the default DiscussionForumPosting schema.

2. A `has_answers` policy in BuildSchemaMarkup that gates on the
materialized accepted_answer/suggested_answers after they've been
fetched, catching any edge cases the topic-level check might miss.

Additionally, `fetch_accepted_answer` now checks post visibility via
`Guardian.new.can_see_post?` (anonymous perspective) so hidden accepted
answers are excluded from schema output rather than being advertised to
search engines. The `"answered only"` setting also uses this visibility
check instead of just testing whether an answer_post_id exists.

https://meta.discourse.org/t/399525
2026-04-02 15:02:15 +02:00
..
controllers/discourse_solved DEV: add service objects for accept_answer and unaccept_answer (#37878) 2026-03-04 12:34:37 +04:00
models/discourse_solved FEATURE: Show editable category type settings in tab(s) (#38143) 2026-03-05 11:44:43 +10:00
serializers FEATURE: solved schema markup for solution posts (#38768) 2026-03-26 08:43:11 +00:00
services/discourse_solved FIX: Skip QAPage schema when topic has no visible answers (#38964) 2026-04-02 15:02:15 +02:00