Open mhkuu opened 1 year ago
After some investigation together with @marinakoleva , this is a technical summary of the culprit:
The source of truth for assessing if a keyword is used elsewhere in the site is the wpseo_taxonomy_meta
option (that's being used in the return WPSEO_Taxonomy_Meta::get_keyword_usage( $focuskw, $this->term->term_id, $this->term->taxonomy );
line of the get_focus_keyword_usage()
method in WPSEO_Term_Metabox_Formatter
.
The issue at hand is that when a term is being deleted, we don't update the wpseo_taxonomy_meta
option with this new information, so any keyword usage is not being updated.
A possible/probable solution is to hook into the delete_term
action in WPSEO_Taxonomy
class (much like we hook into the edit_term
action when a term is updated), so that we can update the wpseo_taxonomy_meta
option.
Once we do that, then wpseoScriptData.metabox.keyword_usage
will contain the updated information even if a term has been deleted.
For the dev that picks this up:
One thing that strikes me as weird is that we have the wpseo_taxonomy_meta
option as the source of the truth here, even though that info exists in the terms' indexables as well.
Maybe a good candidate for improvement in the future?
Original JIRA task (from IM board)
Please give us a description of what happened
By default, if you create a term (e.g., category or tag), it will use the 'name' of the term as the default focus keyphrase. However, if you were to create two terms, and then change the focus keyphrase so that they both share the same focus keyphrase (e.g.
Citizens
), you would then receive the assessment of:Once you delete one of the other terns (there's no 'trash' filter and it mentions permanently deleting), you would expect that the assessment wouldn't appear anymore for the remaining term. But it still shows the same assessment, and when you click on the text link in the 'once before' part of the assessment, it will show you:
You can resolve this for posts by 'permanently deleting' it when going to the 'trash' filter, but there's no option on this for terms. Updating the term, or resetting the data using the Yoast Test Helper plugin doesn't resolve the issue.
To Reproduce
Step-by-step reproduction instructions
example
example
, confirm the keyphrase isexample
duplicate
duplicate
, change the keyphrase fromduplicate
toexample
.example
.duplicate
.example
.once before
gives an error message.Expected results
Actual results
Screenshots, screen recording, code snippet
See some screenshots in the Jira issue.
Technical info
Used versions
trunk
(20.0-RC5)