Open MaggieCabrera opened 1 year ago
I can't find the issue right now, but the Navigation block has the same problem.
This is a general bug with any synced block using database IDs as ref.
I can't find the issue right now, but the Navigation block has the same problem.
This is a general bug with any synced block using database IDs as ref.
true, but for the nav block removing the ID from the block makes it fall back to a list of pages, and the ref is pointing to content. In the case of patterns, we are talking about markup, that is supposed to be part of the theme, not specific to the content of the user's site.
Thanks for clarifying, @MaggieCabrera!
Heads up to @WordPress/block-themers!
I think the solution for this (same as the navigation block) is for the pattern block to reference patterns using a slug instead of an id. It's discussed in the following two issues:
Though I think there would still be additional work to make sure the referenced synced patterns are exported as files.
I just took care of this in a plugin of mine, it could be incorporated into the import / export tool if necessary. One thing that it took me more than 10 years to realize is that the import / export tool tries to keep ids, and referential integrity is only lost when the id is already used by another item. I mentioned it in another issue: https://github.com/WordPress/gutenberg/issues/62566#62686 my solution was to store in an option the ids that where modified (of both navigations and menus) and than perform search replace on the content. Look at lines from 389 to 545 of this file . But if the solution is referencing these objects by slug like suggested by @youknowriad then my fix is not needed. I will keep loving WordPress anyway :)
Description
If you build a theme using reusable blocks and then export the theme (both using the core functionality or Create Block theme plugin) the template exported will have the synced patterns as
<!-- wp:block {"ref":62} /-->
which will not work if you try to run the theme on a different environment. We should fix this, even if it's just resolving those refs into the referenced markup of the pattern upon exporting.Step-by-step reproduction instructions
Create a synced pattern on one of the theme's templates. Export the theme Try installing that theme on a different environment, you will see what's on the screenshot below
Screenshots, screen recording, code snippet
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes