[wp-trac] [WordPress Trac] #53607: Loading or saving a post with enough (large) revisions exhausts available memory

WordPress Trac noreply at wordpress.org
Tue Jul 6 14:22:21 UTC 2021


#53607: Loading or saving a post with enough (large) revisions exhausts available
memory
--------------------------+-----------------------------
 Reporter:  mlbrgl        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Revisions     |    Version:  5.7.2
 Severity:  normal        |   Keywords:
  Focuses:  performance   |
--------------------------+-----------------------------
 This is a follow-up to #34560.


 **What steps should be taken to consistently reproduce the problem?**
 - create a post with enough (large) revisions (see "Steps to reproduce"
 from #34560).
 - Reduce `WP_MAX_MEMORY_LIMIT` so that it is enough to load one revision
 but not enough to load tens / hundreds of revisions (e.g. 128M)
 - save post -> `Updating failed. The response is not a valid JSON
 response.`
 - edit post -> `**Fatal error**: Allowed memory size of 134217728 bytes
 exhausted`


 **Does the problem occur even when you deactivate all plugins and use the
 default theme?**
 - yes

 **Likely cause**
 It seems full post revisions (including post content) are still being
 loaded when editing a post. This is likely the cause of high memory
 consumption. To look into this:

 - on a standard WordPress installation, activate
 [https://wordpress.org/plugins/debug-bar/] with
 {{{#!php
 <?php
 define( 'SAVEQUERIES', true );
 ?>
 }}}
 - edit a post with revisions enabled
 - check the "Queries" tab of the debug bar (might need to turn off
 Gutenberg full screen mode to see it) and look for the query that loads
 the exhaustive list of full revisions (`wp_posts.*`):

 {{{
 SELECT wp_posts.* FROM wp_posts
 WHERE 1=1 AND wp_posts.post_parent = [[THE CURRENT POST ID]]
 AND wp_posts.post_type = 'revision'
 AND ((wp_posts.post_status = 'inherit'))
 ORDER BY wp_posts.post_date DESC, wp_posts.ID DESC
 }}}

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


More information about the wp-trac mailing list