[wp-trac] [WordPress Trac] #59188: WP_Posts_List_Table causes post, postmeta, and term caches to be primed for all pages in the DB on load

WordPress Trac noreply at wordpress.org
Thu Sep 14 09:47:07 UTC 2023


#59188: WP_Posts_List_Table causes post, postmeta, and term caches to be primed for
all pages in the DB on load
--------------------------------+------------------------------------------
 Reporter:  kevinfodness        |       Owner:  spacedmonkey
     Type:  defect (bug)        |      Status:  assigned
 Priority:  normal              |   Milestone:  6.4
Component:  Query               |     Version:
 Severity:  normal              |  Resolution:
 Keywords:  has-patch dev-      |     Focuses:  administration, performance
  feedback                      |
--------------------------------+------------------------------------------

Comment (by spacedmonkey):

 I think the issue here. Per [53941], when fields `id` / `id=>parents` were
 passed, term and meta caches were not primed, even if
 `update_post_term_cache` or `update_post_meta_cache` is passed. See
 [https://github.com/WordPress/wordpress-
 develop/blob/13046ba47ade670d59542b3ef2570b1d85900910/src/wp-includes
 /class-wp-query.php#L3084-L3115 this code snippet]. Now in WP 6.1+, on the
 second run term and meta are primed. See this
 [https://github.com/WordPress/wordpress-
 develop/blob/18fbb97e50af1c4b48d5f1cb3c53011c6a6cbf9e/src/wp-includes
 /class-wp-query.php#L3186 line].

 We could consider doing something like this.

 {{{#!php
                 if ( ! isset( $q['update_post_term_cache'] ) ) {
                        if( 'id=>parent' === $q['fields'] ){
                          $q['update_post_term_cache'] = false;
                        }else{
                           $q['update_post_term_cache'] = true;
                        }
                 }

                 if ( ! isset( $q['update_post_meta_cache'] ) ) {
                         if( 'id=>parent' === $q['fields'] ){
                          $q['update_post_meta_cache'] = false;
                        }else{
                           $q['update_post_meta_cache'] = true;
                        }
                 }
 }}}

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


More information about the wp-trac mailing list