forked from WordPress/WordPress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
get_term()
behave more consistently in the context of shared t…
…erms. When `WP_Term` was introduced in [34997], the `$taxonomy` parameter for `get_term()` was made optional. This meant that, when the optional param was omitted, `get_term()` had no way of determining which term was intended when the term_id was shared between multiple taxonomies. As a (somewhat sneaky) way of fixing things, `get_term()` split any shared terms it found. But this could cause problems with developer expectations: it's not clear why requesting a term should result in a database update, much less a potential change in the ID of a term. In place of this technique, this changeset introduces a number of changes that make the handling of shared terms a bit less insane: * When a taxonomy is provided to `get_term()`, and a cached term is found matching the term_id, make sure the taxonomy also matches before returning it. * When a taxonomy is not provided, ensure that the term is not shared before adding it to the cache. * When a term is shared between taxonomies and no taxonomy is provided, return a `WP_Error` rather than splitting the term. * When a term is shared between taxonomies, only one of which is valid, return the term from that taxonomy. Props boonebgorges, dlh. Fixes #34533. Built from https://develop.svn.wordpress.org/trunk@35537 git-svn-id: http://core.svn.wordpress.org/trunk@35501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
- Loading branch information
1 parent
3caaa70
commit 91a5e4c
Showing
3 changed files
with
59 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters