Opened 3 years ago
Last modified 3 years ago
#56351 new defect (bug)
Shared terms will not apply properly to a post in WordPress 6.0
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.0 |
Component: | Taxonomy | Keywords: | has-unit-tests reporter-feedback |
Focuses: | Cc: |
Description
Starting with WordPress 6.0, and with a databases that still as shared terms, only one taxonomy can be applied to a post.
Having a term that belongs to multiple taxonomies e.g.
+---------+---------------+---------------+----------+ | term_id | name | slug | taxonomy | +---------+---------------+---------------+----------+ | 277 | TermSplitTest | termsplittest | category | | 277 | TermSplitTest | termsplittest | post_tag | +---------+---------------+---------------+----------+ +------------------+---------+----------+-------------+--------+-------+ | term_taxonomy_id | term_id | taxonomy | description | parent | count | +------------------+---------+----------+-------------+--------+-------+ | 472 | 277 | category | | 0 | 8 | | 277 | 277 | post_tag | | 0 | 6 | +------------------+---------+----------+-------------+--------+-------+
A post will apply the term to only one taxonomy e.g. selecting this term as a category will apply this term as a post tag or vice versa. This change was introduced in: https://core.trac.wordpress.org/changeset/52921/
With WordPress 5.9.x the term_exists
function would return the correct term_taxonomy_id
:
term_exists( 277, 'category' ); Array ( [term_id] => 277 [term_taxonomy_id] => 472 ) term_exists( 277, 'post_tag' ); Array ( [term_id] => 277 [term_taxonomy_id] => 277 )
With WordPress 6.0.x term_exists
returns the same term_taxonomy_id
:
term_exists( 277, 'category' ); Array ( [term_id] => 277 [term_taxonomy_id] => 277 ) term_exists( 277, 'post_tag' ); Array ( [term_id] => 277 [term_taxonomy_id] => 277 )
The term will be split if you re-save it in wp-admin
using the category
taxonomy. The same does not happen if you re-save the term in the post_tag
taxonomy. Instead you get an error:
Attachments (1)
Change History (7)
This ticket was mentioned in PR #3077 on WordPress/wordpress-develop by peterwilsoncc.
3 years ago
#1
- Keywords has-patch has-unit-tests added
#2
@
3 years ago
- Keywords has-patch removed
In the linked pull request I've created a test with an unsplit term.
As yet, it does not contain a fix.
#3
@
3 years ago
After further investigation, the underlying cause appears to be [52836] for #37189.
In #37189 the WP_Term_Query
class switched to caching individual term IDs in the main query cache, and them using those IDs to get each individual term object.
On a site with unsplit terms, the WP_Term_Query
cache no longer includes the tt_id relevant to the query.
#4
@
3 years ago
- Keywords reporter-feedback added
@kaygee79 do you know why you still have unsplit terms on your install? For context, I am trying to work out if there is a bug in the unsplitting routine or whether it is a plugin.
#5
@
3 years ago
@peterwilsoncc it's a client site so I don't know the history of it, however, I have come across this on 3 other sites. To be fair, it was only a few terms that were not split. So maybe they were terms that have not been edited since WP4.3 and never migrated for some reason? Totally a guess though.
Error trying to save shared term