[wp-trac] [WordPress Trac] #45366: Optimize wp_get_post_revisions() call in wp_list_post_revisions()

WordPress Trac noreply at wordpress.org
Fri Nov 16 18:40:36 UTC 2018


#45366: Optimize wp_get_post_revisions() call in wp_list_post_revisions()
---------------------------+-----------------------------
 Reporter:  greatislander  |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Revisions      |    Version:  4.9.8
 Severity:  normal         |   Keywords:  needs-patch
  Focuses:  performance    |
---------------------------+-----------------------------
 Currently, `wp_list_post_revisions()` calls `wp_get_post_revisions()` with
 the current post's ID as the only argument. This fetches full post objects
 for each revision. When the current post is very large and has an
 extensive revision history, this can cause out-of-memory issues (this has
 been observed when loading a post with ~43,000 words and 158 revisions).
 While limiting the number of revisions can address this issue, as far as I
 can tell there is no reason to load full post objects for all revisions,
 as all of the subsequently called functions in `wp_list_post_revisions()`
 only require a revision ID. Calling `wp_get_post_revisions( $post->ID,
 array( 'fields' => 'ids' ) )` significantly improves the performance of
 this function under such circumstances.

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


More information about the wp-trac mailing list