wordpress-seo icon indicating copy to clipboard operation
wordpress-seo copied to clipboard

Information stored in wpseo_taxonomy_meta in the wp_options won't be cleaned up

Open apermo opened this issue 7 years ago • 23 comments

  • [x] I've read and understood the contribution guidelines.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened.

When deleting a category, post_tag, custom_taxonomy, the information, stored inside the option 'wpseo_taxonomy_meta' won't be deleted, though these information are lost forever, since they are bound to an id, which will never be given again.

Please describe what you expected to happen and why.

Obviously, delete the information alongside with deleting a term within a taxonomy.

How can we reproduce this behavior?

  1. Create a term(category)
  2. open and edit it, give it something to store in the wpseo_taxonomy_meta
  3. delete the freshly created term
  4. check the database

Technical info

  • WordPress version: 4.9.8
  • Yoast SEO version: 8.4
  • If relevant, which editor is affected (or editors):
  • [ ] Classic Editor
  • [ ] Gutenberg
  • [ ] Classic Editor plugin
  • Which browser is affected (or browsers):
  • [ ] IE11
  • [ ] Edge
  • [ ] Chrome
  • [ ] Firefox
  • [ ] Safari
  • Relevant plugins in case of a bug:
  • Tested with theme:

apermo avatar Oct 12 '18 15:10 apermo

Thanks for reporting this bug! I've been able to confirm this. I’ve marked it correctly so it appears on the to-do list for our developers.

benvaassen avatar Oct 18 '18 08:10 benvaassen

Please inform the customer of conversation # 587163 when this conversation has been closed.

amboutwe avatar Feb 21 '20 20:02 amboutwe

So, just providing some context on this for people running into this and for if this needs to get fixed. When a taxonomy gets deleted, we don't delete the associated WPSEO data from the wpseo_taxonomy_meta option. I think this will be solved in a future project. However, for manually cleaning up, the best way is to see if the IDs of the different options still exists in the wp_terms table.

Looking at a small example of wpseo_taxonomy_meta:

a:2:{s:8:"category";a:1:{i:2;a:2:{s:13:"wpseo_linkdex";s:2:"28";s:19:"wpseo_content_score";s:1:"0";}}s:8:"post_tag";a:2:{i:95;a:3:{s:10:"wpseo_desc";s:30:"srtjstyj tsyjstyj dt dtyj dtyj";s:13:"wpseo_linkdex";s:2:"31";s:19:"wpseo_content_score";s:2:"60";}i:93;a:4:{s:10:"wpseo_desc";s:8:"sfdhsfgh";s:13:"wpseo_focuskw";s:11:"tdkxdtk dfg";s:13:"wpseo_linkdex";s:2:"24";s:19:"wpseo_content_score";s:2:"30";}}}

This contains data for the category and post_tag taxonomies. In the post_tag taxonomy there is an array of 2 items:

i:95;a:3:{s:10:"wpseo_desc";s:30:"srtjstyj tsyjstyj dt dtyj dtyj";s:13:"wpseo_linkdex";s:2:"31";s:19:"wpseo_content_score";s:2:"60";}
i:93;a:4:{s:10:"wpseo_desc";s:8:"sfdhsfgh";s:13:"wpseo_focuskw";s:11:"tdkxdtk dfg";s:13:"wpseo_linkdex";s:2:"24";s:19:"wpseo_content_score";s:2:"30";}

These are for the tags with IDs 95 and 93. I have already deleted the tag with ID 95 so this data is outdated and could be removed.

However, to the question why would you delete this data? I don't believe this option has a large impact on normal sites. If you have thousands upon thousands of taxonomies with different SEO metadata, it might cause some impact, but I am unable to test or verify this claim.

Djennez avatar Mar 06 '20 13:03 Djennez

Conv # 587163 said

Because this value is in the wp_options table and has autoload = yes That means this value is parsed on every page load. So 2.4 Mb is loaded every time making my site slow.

Note: Customer provided us with the data stored in the field. I noticed quite a few empty data strings. (Screenshot below.) Do we need to store empty strings?

selection_154

amboutwe avatar Mar 09 '20 17:03 amboutwe

Please inform the customer of conversation # 628267 when this conversation has been closed.

Pcosta88 avatar Jul 07 '20 17:07 Pcosta88

Please inform the customer of conversation # 634424 when this conversation has been closed.

rmarcano avatar Jul 29 '20 21:07 rmarcano

Please inform the customer of conversation # 647116 when this conversation has been closed.

Pcosta88 avatar Sep 08 '20 13:09 Pcosta88

Please inform the customer of conversation # 679177 when this conversation has been closed.

rmarcano avatar Dec 17 '20 16:12 rmarcano

Please inform the customer of conversation # 750636 when this conversation has been closed.

4ort0 avatar Jun 22 '21 19:06 4ort0

Please inform the customer of conversation # 805049 when this conversation has been closed.

josevarghese avatar Aug 30 '21 13:08 josevarghese

Please inform the customer of conversation # 835226 when this conversation has been closed.

rmarcano avatar Nov 03 '21 21:11 rmarcano

Please inform the customer of conversation # 863970 when this conversation has been closed.

suascat avatar Feb 02 '22 07:02 suascat

Please inform the customer of conversation #889444 when this conversation has been closed.

ogodoabiola avatar Apr 30 '22 16:04 ogodoabiola

Please inform the customer of conversation # 1003486 when this conversation has been closed.

maybellyne avatar Mar 31 '23 10:03 maybellyne

Please inform the customer of conversation # 1021202 when this conversation has been closed.

ogodoabiola avatar May 25 '23 14:05 ogodoabiola

Please inform the customer of conversation # 1071308 when this conversation has been closed.

ogodoabiola avatar Nov 02 '23 08:11 ogodoabiola

Please inform the customer of conversation # 1110008 when this conversation has been closed.

detolah avatar Feb 29 '24 07:02 detolah

Please inform the customer of conversation # 1134424 when this conversation has been closed.

maybellyne avatar May 14 '24 19:05 maybellyne

Hi @Djennez, given that this issue apparently keeps popping up in support requests again and again over the years, do you plan to add logic that cleans up the wpseo_taxonomy_meta option on term deletion at some point?

However, to the question why would you delete this data? I don't believe this option has a large impact on normal sites. If you have thousands upon thousands of taxonomies with different SEO metadata, it might cause some impact, but I am unable to test or verify this claim.

Well, the simplest answer is data minimization and preventing "data garbage" on your customer's systems as much as possible. But more importantly, there are real-life cases where this ever-growing option causes issues, e.g., here: https://wordpress.org/support/topic/wpseo_taxonomy_meta-causing-and-autoloaded-data/.

TBH, I'm surprised cleaning up hasn't been introduced after all those years, given that this is a really simple fix: Hook to the delete_term action, check the wpseo_taxonomy_meta option for the term ID, and delete it if present. Additionally, a one-time migration script should run over all term IDs stored in the option to check if the terms still exist. If not, delete the key.

I'd really appreciate it if you could consider adding this! Thanks!

tyrann0us avatar Jun 05 '24 11:06 tyrann0us

Please inform the customer of conversation # 1163634 when this conversation has been closed.

detolah avatar Aug 15 '24 13:08 detolah