A platform for community discussion. Free, open, simple.
FIX: deleted topic author in crawler view (#27788)
Régis Hanol0846862cb5b2
diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erbindex 54d030d1106..90f8f020515 100644--- a/app/views/topics/show.html.erb+++ b/app/views/topics/show.html.erb@@ -52,10 +52,12 @@</div><% if @topic_view.crawler_posts&.first && !@topic_view.crawler_posts.first.is_first_post? %>- <span itemprop='author' itemscope itemtype="http://schema.org/Person">- <meta itemprop='name' content='<%= @topic_view.topic.user.username %>'>- <link itemprop='url' href='<%= Discourse.base_url %>/u/<%= @topic_view.topic.user.username %>'>- </span>+ <% if @topic_view.topic.user.present? %>+ <span itemprop='author' itemscope itemtype="http://schema.org/Person">+ <meta itemprop='name' content='<%= @topic_view.topic.user.username %>'>+ <link itemprop='url' href='<%= Discourse.base_url %>/u/<%= @topic_view.topic.user.username %>'>+ </span>+ <% end %><meta itemprop='text' content='<%= @topic_view.topic.excerpt %>'><% end %>diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rbindex a60f1633f39..b3bc9de4cbe 100644--- a/spec/requests/topics_controller_spec.rb+++ b/spec/requests/topics_controller_spec.rb@@ -5382,6 +5382,12 @@ RSpec.describe TopicsController do)end+ it "works even when the author has been deleted" do+ topic.update!(user_id: nil)++ get "#{topic.relative_url}/2"+ end+context "with canonical_url" dofab!(:topic_embed) { Fabricate(:topic_embed, embed_url: "https://markvanlan.com") }let!(:user_agent) do