You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem code is located here. PRs are welcome 🙂
Aside from the double counting the duplicate post_id+tag_id rows in the posts_tags table does not appear to cause any other issues. Deleting the attached tag from the UI correctly deletes both rows.
If you're aware of any other problems this causes please elaborate.
As for the fix there are two approaches:
Add a check to the bulk edit feature to skip inserting duplicate rows
Add a unique index across the posts_tags.{post_id,tag_id} columns so data integrity is ensured at the database level (this will likely also require approach 1 or a similar handling of errors during the insert, as well as a migration to remove duplicates before the unique index is added)
kevinansfield
changed the title
Double Tag count when adding existing tag via Context Menu
Bulk adding tags can create "duplicate" post_tags rows
Oct 28, 2024
kevinansfield
changed the title
Bulk adding tags can create "duplicate" post_tags rows
Bulk adding tags can create "duplicate" posts_tags rows
Oct 28, 2024
Issue Summary
Tag count doubled when adding an existing tag in a post again via Context Menu.
The correct behaviour would be, if a tag is already existed in a post, it should not be tagged again using "Add a Tag" in Context Menu.
Steps to Reproduce
Ghost Version
5.94
Node.js Version
22
How did you install Ghost?
Linux / Local
Database type
MySQL 8
Browser & OS version
No response
Relevant log / error output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: