Opened 5 years ago
Last modified 8 months ago
#53607 new defect (bug)
Loading or saving a post with enough (large) revisions exhausts available memory
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 5.7.2 |
| Component: | Revisions | Keywords: | |
| Focuses: | performance | Cc: |
Description
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_LIMITso 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 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
Attachments (3)
Change History (5)
@
5 years ago
The likely offending query exhausting available memory on posts with enough large revisions
#1
@
8 months ago
Thank you for the report @mlbrgl, and welcome to Trac. Apologies for this only being reviewed now after all this time.
Is this still a problem you're facing? Would it be an option to limit the number of revisions that are saved for a post?
Overall, this seems like a valid issue, but I'm unsure how it could be addressed other than having adequate memory limit. Do you have any suggestions?
cc @spacedmonkey @adamsilverstein for visibility
Saving a post with enough large revisions