Skip to content

Conversation

@peterwilsoncc
Copy link
Contributor

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


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

Copy link
Contributor Author

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notes to self...

Could be a problem if a taxonomy is registered for two primitive object types, eg register_taxonomy( 'pwcc', [ 'post', 'user' ], $args ), but it's a little out of warranty as there is no way of knowing if the relationship refers to post 1, or user 1.

*
* @param bool $new_setting The new setting for preventing term counts.
* @param int $object_id The ID of the object.
* @param string $object_type Optional. Type of object: post, comment, term, user or site. Default post.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param string $object_type Optional. Type of object: post, comment, term, user or site. Default post.
* @param string $object_type Optional. Type of object primitive: post, comment, term, user or site. Default post.

if ( array_filter( $object_types, 'post_type_exists' ) !== $object_types ) {
// This taxonomy applies to non-posts, count changes now.
$do_recount = ! _wp_prevent_term_counting();
$do_recount = ! _wp_prevent_term_counting( $object_id, reset( $object_types ) );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be good here to make sure it's using the correct primitive.

@Chouby
Copy link

Chouby commented Oct 28, 2020

Could be a problem if a taxonomy is registered for two primitive object types, eg register_taxonomy( 'pwcc', [ 'post', 'user' ], $args ), but it's a little out of warranty as there is no way of knowing if the relationship refers to post 1, or user 1.

Indeed, we can't do that for the exact reason that you exposed. In Polylang I had this need (define a taxonomy 'language' for posts and terms). Due to the fact that we cannot tell if the relationship refers to posts or terms or anything else, I needed to register 2 taxonomies, one for posts, one for terms.

@peterwilsoncc peterwilsoncc deleted the 51630-ptc-improve-preventing-double-counts branch October 30, 2020 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants