[wp-trac] [WordPress Trac] #57966: High number of call to sanitize_term in wp_queue_posts_for_term_meta_lazyload

WordPress Trac noreply at wordpress.org
Fri Mar 31 21:40:38 UTC 2023


#57966: High number of call to sanitize_term in
wp_queue_posts_for_term_meta_lazyload
--------------------------+---------------------------
 Reporter:  spacedmonkey  |       Owner:  spacedmonkey
     Type:  enhancement   |      Status:  assigned
 Priority:  normal        |   Milestone:  6.3
Component:  Taxonomy      |     Version:  6.2
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  performance
--------------------------+---------------------------

Comment (by joemcgill):

 Thank you for the context, I think I understand better what is happening
 here. `get_object_term_cache()` calls `get_term()` because it expects that
 only IDs are being returned by `wp_cache_get( $id,
 "{$taxonomy}_relationships" )`. Since that function wants to return a list
 of `WP_Term` objects, the error check is there to make sure no `WP_Error`
 objects are mixed in.

 The individual calls to `get_term()` also explains why the function calls
 `_prime_term_caches` prior to looping through the IDs.

 Since one of the base assumptions of
 `wp_queue_posts_for_term_meta_lazyload` is that it will only work if the
 term cache has already been primed, and because we are only trying to get
 a list of term IDs to queue (not full objects), I think the second
 approach should be fine. The lazy loader should be responsible for making
 sure any term IDs it is loading are valid term objects regardless (not
 sure if it is actually implemented that way), but I agree that we
 shouldn't need to add an additional check here.

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


More information about the wp-trac mailing list