Skip to content

Taxonomy: Fix cache issue in get_the_terms #211

New issue

Have a question about this project? Sign up for a free account to open an issue and contact its maintainers and the community.

By clicking “Sign up for ”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on ? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dingo-d
Copy link
Member

@dingo-d dingo-d commented Apr 3, 2020

Loosened the condition to check the terms fetched fro mthe object term cache. The cache can return an empty array, which is a falsy value, so the get_the_terms will return false value.

Trac ticket: https://core.trac.wordpress.org/ticket/49799


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See Pull Requests for Code Review in the Core Handbook for more details.

Loosened the condition to check the terms fetched fro mthe object term cache. The cache can return an empty array, which is a falsy value, so the get_the_terms will return false value.
@dingo-d
Copy link
Member Author

dingo-d commented Apr 3, 2020

Also, maybe a good thing to note is that I'm assigning the terms in my tests using wp_set_object_terms(); function. The same thing happened when I tried wp_set_post_terms(), so it could be something related to that (test env could mess with the object caching?).

I'm wondering: in the case there is nothing in the post (no assigned term), the

$term_ids = wp_list_pluck( $terms, 'term_id' );
wp_cache_add( $post->ID, $term_ids, $taxonomy . '_relationships' );

will write empty array to the cache. Is this ok or is it redundant?

@github-actionsGitHub Actions
Copy link

-actions bot commented Mar 13, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their and WordPress.org accounts: @hidomib321.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dingo_d.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Sign up for free to join this conversation on . Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
@dingo-d