FIX: topic embed blank tags or passed with nil do not blank out existing topic tags (#27699)

When a topic embed is run with either no tags argument or a nil tag argument
this should not affect any existing tags.

Only update topic tags when tags argument is explicitly empty.
This commit is contained in:
Jeff Wong
2024-07-03 14:50:59 -07:00
committed by GitHub
parent 3a6762d2be
commit 70fc39211b
2 changed files with 13 additions and 1 deletions

View File

@@ -124,7 +124,7 @@ class TopicEmbed < ActiveRecord::Base
existing_tag_names = post.topic.tags.pluck(:name).sort
incoming_tag_names = Array(tags).map { |tag| tag.respond_to?(:name) ? tag.name : tag }.sort
tags_changed = existing_tag_names != incoming_tag_names
tags_changed = !tags.nil? && existing_tag_names != incoming_tag_names
if (content_sha1 != embed.content_sha1) || (title && title != post&.topic&.title) ||
tags_changed