-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deleting a block or template does not delete postmeta #45
Comments
For me this is not a bug. Conceptually, you can use the same meta in several blocks in Gutenberg. Deleting a meta shouldn't be achievied by the removal of a block, but by the removal of the value inside the block. Maybe deleting a field from a template should delete this meta for all posts, but I'm not yet sold on the idea. |
Keeping the meta makes sense if any block on the post uses the same postmeta key and remains in the content, definitely. (When I say "block" I mean a template block) This is how I'm thinking of it though: say I have a paragraph block where I've written something and I've decided that it's a horrible horrible paragraph so I delete the block. I assume that the paragraph is gone and won't show up on the post. This isn't true of the template blocks — I wouldn't think to delete the content of the template block field by field then save the empty block, the same way I wouldn't think to delete the content of the paragraph block and save an empty paragraph block. Also, thinking about this, I am not sure your example works there either. If I delete the contents of one block and there's another on the page with values, which one takes precedence? I get where you're coming from — meta is different! It's stored differently and can be used differently. The brilliance of Gutenberg though is that the user now doesn't need to know any of that, they can just add and delete blocks and assume if it's there it will work the same as all the rest. But what an interesting discussion, thank you! I had never thought through what happens to postmeta when a block is registered and uses 'meta' as an attribute type and an instance is deleted, mainly because I've only used the dynamic render for those so the issue didn't show up. :) |
they are synced, so whatever you update on a block, it's updated on the other blocks too. Maybe the way forward is to add an explicit "reset value" on each of the fields. |
When a block or template is deleted, the postmeta is not deleted. This is an issue because in templates, the data will be retrieved using
get_post_meta
.Reproduce:
You can keep an eye on the postmeta table to see that it's still there or put a filter on the content to view it (at the bottom)
There are a couple of ways of fixing:
I think the first is the way to go as it avoids the orphaned data issue.
Cheap and cheerful content filter:
The text was updated successfully, but these errors were encountered: