[wp-trac] [WordPress Trac] #40351: Term post re-counts scale poorly, are common and difficult to avoid

WordPress Trac noreply at wordpress.org
Sat Sep 19 04:14:47 UTC 2020


#40351: Term post re-counts scale poorly, are common and difficult to avoid
-------------------------------------------------+-------------------------
 Reporter:  mattoperry                           |       Owner:  whyisjake
     Type:  enhancement                          |      Status:  assigned
 Priority:  normal                               |   Milestone:  5.6
Component:  Taxonomy                             |     Version:  4.8
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-testing early        |     Focuses:
  needs-dev-note has-unit-tests                  |  performance
-------------------------------------------------+-------------------------

Comment (by peterwilsoncc):

 In updated [https://github.com/WordPress/wordpress-develop/pull/519/files
 pull request #519]:

 * unit tests for term counts, they pass on both trunk and the branch now
 :)
 * `register_taxonomy()` accepts a new argument `update_count_by_callback`
 for incrementing and decrementing term count. For backcompat it calls
 `update_count_callback` if it's defined by "count_by" is not
 * A new function `_wp_prevent_term_counting()` used to prevent double
 counting when adding terms within `wp_insert_post()` and
 `wp_publish_post()`
 * DB queries are deferred until the final numbers are known when
 transitioning post counts to reduce the number of `UPDATE` calls
 * `wp_set_object_terms()` and `wp_remove_object_terms()` now check the
 taxonomies object type to determine whether the counts should be updated
 immediately
 * All of Core's calls to the older functions have been removed

 Questions:

 * Has anything been missed?
 * Should I be checking trashing and deleting posts too in the unit tests?
 * Is `_wp_prevent_term_counting()` too much of a hack and using a
 reflection preferable?
 * Has anything been missed (yes, asking this question twice)?

 As the definition of `early 5.6` is beginning to be stretched some
 additional eyes on this would be superb.

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


More information about the wp-trac mailing list