[wp-trac] [WordPress Trac] #41813: get_terms is hiding taxonomies that are not empty

WordPress Trac noreply at wordpress.org
Thu Jun 8 14:21:31 UTC 2023


#41813: get_terms is hiding taxonomies that are not empty
------------------------------+------------------------------
 Reporter:  subrataemfluence  |       Owner:  (none)
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Taxonomy          |     Version:  4.8.1
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:
------------------------------+------------------------------

Comment (by ramon fincken):

 The issue is in _update_post_term_count

 on

 {{{
                 // Attachments can be 'inherit' status, we need to base
 count off the parent's status if so.
                 if ( $check_attachments ) {
 }}}

 this code does only account for attachments that are inserted fresly
 (uploaded) on a CPT and not single attachments

 if I run this manually for item 5 which is used 2 times the output is
 actually 2



 {{{
 SELECT COUNT(*) FROM wp_term_relationships, wp_posts p1
         WHERE p1.ID = wp_term_relationships.object_id
         AND (
                 post_status IN ('publish') OR
                 (
                         post_status = 'inherit'
                          -- AND post_parent > 0
                          -- AND ( SELECT post_status FROM wp_posts WHERE
 ID = p1.post_parent ) IN ('publish')
         )
         )
         AND post_type = 'attachment'
         AND term_taxonomy_id = 5;
 }}}

 It goes wrong on the post_parent which is zero AND the second line for
 there is no post_parent to check

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/41813#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list