Skip to content
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

Removing a block containing a "save in Meta" field does not clear the post meta field in DB #294

Closed
janwidmer opened this issue Aug 6, 2023 · 2 comments · Fixed by #331
Labels
enhancement New feature or request

Comments

@janwidmer
Copy link
Contributor

Issue description:

I am using some blocks with fields with the "Save in Meta" Options. Those are mostly Stage components being used at the top of the page to display an large image. The image field uses the option "Save in meta" so that I can also use this image to display teasers to sucht pages.

This works so far. The problem is, that the entry in the post_meta database table is not getting removed properly, when the block is being removed from the page.

Steps to reproduce:

  1. Import this block lzb-export-blocks-2023-08-06.json.zip
  2. Place it on a page and fill out the fields, the field "Bühne Bild" Contains the stage image
  3. When saving the page, a db entry to the post_meta table get's made containing the image information
  4. When removing this block from the page again, the entry in the post_meta table remains
  5. This is a problem, since my index.php page checks for the post meta entry to decide if a page title block should be displaye as fallback or not (because the stage block is there)

Lazy Blocks Version:

3.4.4

WordPress Version:

6.2.2

Any helpful information to reproduce the issue (screenshots, code parts)

A potentiall workaround would be to use the post save filter and somehow figure out if a stage block is in the content and if not, remove the entry in the post_meta table. Another potential workaround could be to use the js actions / filters..

@nk-o
Copy link
Collaborator

nk-o commented Aug 16, 2023

It is a good suggestion, but we should make it better.

I don't think we should remove silently the post meta, because it can be used by 3rd-parties.
Even if the user decides not to use Lazy Blocks anymore, their posts and post templates may still use meta fields.

Also, blocks may be removed by accident and meta will be removed.

We can try to prevent removing such blocks and ask the user in a simple popup first.
For example:

Shot 2023-08-16 at 08 58 46

To make it possible, we should check these things:

  • Ensure that we can prevent block removal action using Gutenberg API
  • In case the user removes a bunch of blocks, we should parse all selected and inner blocks

@nk-o nk-o added the enhancement New feature or request label Aug 16, 2023
@janwidmer
Copy link
Contributor Author

Sounds like a good solution

@Fellan-91 Fellan-91 linked a pull request Nov 28, 2024 that will close this issue
@nk-o nk-o closed this as completed in #331 Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants