WordPress database error Duplicate entry for key ‘slug’
I have just migrated to a new host and upgraded my WordPress to 4.9.8 (from 3.9.x, embarrassing I know, plan to keep it up to date from now on).
I also went through the process of replacing plugins that were not maintained and updating everything. Once I was done, I exported my PHP logs to make sure that everything was running smoothly and I found this error message being spammed (hundreds of lines per day):
[24-Nov-2018 06:25:10 UTC] WordPress database error Duplicate entry 'gaming-laptops' for key 'slug' for query INSERT INTO `wp_terms` (`name`, `slug`, `term_group`) VALUES ('Gaming Laptops', 'gaming-laptops', 0) made by do_action_ref_array, WP_Hook->do_action, WP_Hook->apply_filters, _wp_batch_split_terms, _split_shared_term
I have done some research about repairing the database, which I am happy to do but I am just a little nervous about causing further damage. If anyone has experience in this type of issue and could point me in the right direction, I would really appreciate it.
P.S: Most of the other stuff I found while trying to fix referred to having an issue with the primary key. I don’t think this applies because unlike their error log, my one does not mention that.
UPDATE 1: Thanks to feedback, I found a tag that had the slug of “gaming-laptops”, which is obviously causing the error. However, when I try to delete the tag (removed it off the single post that it was attached to first), I get this error message:
… and if I try to edit it (so that it has a different slug):
NOTE: I didn’t mention it directly, but I have a category called “Gaming Laptops” (slug is gaming-laptops), that is why I think that this is an obvious conflict and the reason for the error messages.
Leave an answer