[wp-trac] [WordPress Trac] #50567: Set $post filter in update_post_cache()

WordPress Trac noreply at wordpress.org
Mon Jul 6 03:19:08 UTC 2020


#50567: Set $post filter in update_post_cache()
-------------------------------+-----------------------------
 Reporter:  Cybr               |      Owner:  (none)
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  trunk
 Severity:  normal             |   Keywords:
  Focuses:  performance        |
-------------------------------+-----------------------------
 `update_post_cache()` stores each post provided in the cache, the same
 cache `WP_Post::get_instance()` uses. But in doing so, it doesn't
 necessarily add a `$filter` to the post.

 Because of this, `WP_Post::get_instance()` will always re-sanitize the
 post whenever a post stored prior via `update_post_cache()` is requested--
 since `WP_Post::get_instance()` tests for `empty( $_post->filter )` after
 retrieving the post back from cache (but doesn't repopulate the post
 cache).

 This re-sanitization most prominently happens at `wp-admin/edit.php`,
 where each post displayed goes through this process about 24 times (on a
 clean WP installation).

 To address this issue, we should prime the post cache with a `$filter`.
 The file attached will already improve the aforementioned page's load time
 by 62%--it's quite substantial.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50567>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list