Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

All purges happen twice with Gutenberg Editor #86

Open
ckeeney opened this issue Jan 30, 2020 · 2 comments
Open

All purges happen twice with Gutenberg Editor #86

ckeeney opened this issue Jan 30, 2020 · 2 comments

Comments

@ckeeney
Copy link

ckeeney commented Jan 30, 2020

When a post is saved using the Gutenberg editor, the editor makes two separate requests to save all the data: one request to save metaboxes and one request to save the post itself. Both of these requests dispatch a save_post event. As a result, all of the purges happen twice. This is causing performance issues: most notably, it worsens the slow saving of posts documented in #56.

There are a few workarounds in the comments at WordPress/gutenberg#12903, but I'm not sure which is best.

@Ipstenu
Copy link
Owner

Ipstenu commented Jan 30, 2020

The issue, as mentioned in Gutenberg's ticket, is that Gutenberg itself is saving twice IF there's a meta box. There's no easy way to check if something is gutenberg and if it did (or didn't) already save the meta, so you kind of have to deal with a double purge until there's a better hook :(

Also most of the proposed fixes require knowing the post type you're hooking into (post, pages, custom...) which I can't know. Unlike the fix used for social media posts, we want to run on update as well as on initial post, but it's possible to take some of https://gist.github.com/n7studios/56fd05f19f5da26f19f6da0ccb57b144#file-post-to-social-php-L67 and use that to determine. I'll mess around with it.

FWIW since I'm not watching post transitions in the same way, it's not a 1-to-1 same situation :/

@ckeeney
Copy link
Author

ckeeney commented Jan 30, 2020

I agree the most ideal solution involves changes to WP Core hooks. I just noticed the duplicate purge requests and wanted to document the behavior here so people didn't spend time investigating something I already researched.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants